URL with data help

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 ?

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.

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 :slight_smile: