Okay, am going nuts trying to get this to work. I want to pass information I need to the new action and it ain't working. I am in a view and using link_to with a path to create a new record:
<%= link_to "New", new_libation_path(:xid=> 123) %>
My routes table has: resources 开发者_如何转开发:libations
And in the libation_controller I have my new action...
def new
puts params[:xid] #This is nil!
...
What am I doing wrong? Maybe I should google how to use params in rails..
This looks right. Is the query string in the URL showing up as it should? Check on your rails console that app.new_libation_path(:xid => 123)
is returning the correct URL, and that this URL is showing up in your HTML markup:
ruby-1.9.2-p136 :001 > app.new_user_path(:test => 'test')
=> "/users/new?test=test"
(from an app I had handy)
精彩评论