0
我新的軌道,並有問題,我的路線。當鏈路被提交,就應該去「http://example.com」雖然現在進入到本地主機:3000 /鏈接/ www.example.com 我運行紅寶石3.2.8和ruby1.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>
我控制器設置爲:
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
在我development.rb文件我有:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
我的路線是:
resources :pages
resources :links
root :to => "pages#index"
無數年代後因爲我是初學者,所以我沒有運氣。有關如何重置鏈接路徑的任何建議非常感謝。
非常有幫助謝謝! – pipebender