Im want to put some data on a url and take it to another page were it will be put in a text box. I tried to ad it to the link like this but ut says I have a nil object. <%= link_to ''Rate this product'', new_rating_path(@product.item_name) %> I want to put it into this textbox <%= f.text_field :item_name %> Can anyone help as this is really puzzling me ? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
If you want to pass it in the params, you should name the data item... link_to ''Rate this product'', new_rating_path(:product_name => @product.item_name) Then in the new method for the ratings controller, simply check for that params value: def new @rating = Rating.new if params[:product_name] @rating.item_name = params[:product_name] end respond_to do |format| blah blah blah end end In your view, the item_name data should be there. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ar Chron wrote:> If you want to pass it in the params, you should name the data item... > > link_to ''Rate this product'', new_rating_path(:product_name => > @product.item_name) > > Then in the new method for the ratings controller, simply check for that > params value: > > def new > @rating = Rating.new > if params[:product_name] > @rating.item_name = params[:product_name] > end > respond_to do |format| > blah blah blah > end > end > > In your view, the item_name data should be there.Thanks, thats so simple and i''m so stupid. Why does ruby keep doing this to me :(. Thanks again :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---