# URL with data help

**URL:** <https://www.ruby-forum.com/t/url-with-data-help/133190>\
**Category:** Rails\
**Created:** [March 28, 2008, 4:28pm UTC](https://www.ruby-forum.com/t/url-with-data-help/133190 "2008-03-28T16:28:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 28, 2008, 4:28pm UTC](https://www.ruby-forum.com/t/url-with-data-help/133190/1 "2008-03-28T16:28:09Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 28, 2008, 5:17pm UTC](https://www.ruby-forum.com/t/url-with-data-help/133190/2 "2008-03-28T17:17:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 28, 2008, 6:20pm UTC](https://www.ruby-forum.com/t/url-with-data-help/133190/3 "2008-03-28T18:20:07Z")

</div>

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 🙂
