0
레일을 처음 사용하고 경로에 문제가 있습니다. 링크가 제출되면 이제는 localhost : 3000/links/www.example.com으로 이동하지만 'http://example.com'으로 가야합니다. 나는 루비 3.2.8 및 루비 1.9.3p194를 실행 중입니다. 얼마나 많은 정보가 필요한지 잘 모릅니다. 여기 그것이있는 곳입니다. 내보기에 내가 가진 :레일 경로를 URL 경로로 설정하십시오.
<p>
<h1><%= @link.title %></h1>
<%= link_to @link.url, @link.url %><br />
<p>Posted by: <% @link.user %> at <%= @link.created_at %></p>
</p>
내 컨트롤러로 설정됩니다
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
을 그리고 내 경로는 다음과 같습니다 : 내 development.rb 파일에서
class LinksController < ApplicationController
def show
@link = Link.find(params[:id])
end
before_filter :authenticate_user!
def new
@link = Link.new
end
def create
@link = Link.new(params[:link])
respond_to do |format|
if @link.save
format.html { redirect_to @link, notice: 'Link was successfully created.' }
format.json { render :json => @link, status: :created, location: @link }
else
format.html { render :action => "new" }
format.json { render :json => @link.errors, :status => :unprocessable_entity }
end
end
end
end
내가 가진
을
resources :pages
resources :links
root :to => "pages#index"
무수한 s earches, 나는 초보자부터 운이 없었어. 링크 경로를 재설정하는 방법에 대한 제안은 대단히 감사하겠습니다.
매우 도움이되는 감사합니다! – pipebender