# Link\_to

**URL:** <https://www.ruby-forum.com/t/link-to/79883>\
**Category:** Rails\
**Created:** [December 20, 2006, 7:32am UTC](https://www.ruby-forum.com/t/link-to/79883 "2006-12-20T07:32:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stewart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@Stewart](https://www.ruby-forum.com/u/Stewart)\
**Post date:** [December 20, 2006, 7:32am UTC](https://www.ruby-forum.com/t/link-to/79883/1 "2006-12-20T07:32:22Z")

</div>

quick question about link\_to

if i wanted to pass an id using link to i could do something like  
this…

\<%= link\_to “somewhere”, :action =\> “someaction”, :id =\> somerecord %\>

What if i wanted to send 2 id’s with the link to? How would i do that

So when the action i am linking to is called i have params[:id] and  
params[:id2] both set

\<%= link\_to “somewhere”, :action =\> “someaction”, :id =\> somerecord, id2  
=\> someotherrecord %\>

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![Stewart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@Stewart](https://www.ruby-forum.com/u/Stewart)\
**Post date:** [December 20, 2006, 8:50am UTC](https://www.ruby-forum.com/t/link-to/79883/2 "2006-12-20T08:50:52Z")

</div>

link\_to “somewhere”, { :action =\> “someaction”, :id =\> somerecord, :id2  
=\>  
otherrecord } perhaps.

---

<div class="post-metadata">

**Author:** ![Stewart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@Stewart](https://www.ruby-forum.com/u/Stewart)\
**Post date:** [December 20, 2006, 10:47am UTC](https://www.ruby-forum.com/t/link-to/79883/3 "2006-12-20T10:47:58Z")

</div>

Remember that params is just a hash. As long as you have something to  
catch the keys in the controller, they can be anything you want. You  
may have to do it like this though:

link\_to “somewhere”, :action =\> “someaction”, {:id =\> somerecord, :id2  
=\> otherrecord }

---

<div class="post-metadata">

**Author:** ![Stewart](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/90db22/32.png) [@Stewart](https://www.ruby-forum.com/u/Stewart)\
**Post date:** [December 21, 2006, 5:00am UTC](https://www.ruby-forum.com/t/link-to/79883/4 "2006-12-21T05:00:48Z")

</div>

Taylor S. wrote:

> Remember that params is just a hash. As long as you have something to  
> catch the keys in the controller, they can be anything you want. You  
> may have to do it like this though:
> 
> link\_to “somewhere”, :action =\> “someaction”, {:id =\> somerecord, :id2  
> =\> otherrecord }

ahh the hash… thats what i was missing. Thanks for the help
