# Link\_to

**URL:** <https://www.ruby-forum.com/t/link-to/145601>\
**Category:** Rails\
**Created:** [August 11, 2008, 11:38pm UTC](https://www.ruby-forum.com/t/link-to/145601 "2008-08-11T23:38:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [August 11, 2008, 11:38pm UTC](https://www.ruby-forum.com/t/link-to/145601/1 "2008-08-11T23:38:01Z")

</div>

Hi,

I guess my question is: how can I pass an array as a parameter with  
link\_to.

Just say in index action: @stuff = Model.find(:all)  
Then in view I have: link\_to and pass the whole array @stuff to the next  
action.

Thanks

---

<div class="post-metadata">

**Author:** ![jturney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/e99b99/32.png) [@jturney](https://www.ruby-forum.com/u/jturney)\
**Post date:** [August 12, 2008, 10:42pm UTC](https://www.ruby-forum.com/t/link-to/145601/2 "2008-08-12T22:42:00Z")

</div>

> Then in view I have: link\_to and pass the whole array @stuff to the next  
> action.  
> In your view your link\_to should link to an action in a controller. The  
> action in that controller should then be responsible for gathering data  
> from the model (just like the action you used to get to this page).

What you’re describing seems to be to be a violation of MVC. It’s your  
application, but I hope you understand the implications of doing that.

For example:

1. What happens if the data changes from the time the initial page is  
displayed and the user finally clicks on the link. Are you planning on  
passing them stale data in your array?

2. How much additional bandwidth will you be consuming by passing in an  
array of objects through a request?

3. How do you plan on serializing that array into a steam that can be  
passed through a HTTP request?

Justin To wrote:

> Hi,
> 
> I guess my question is: how can I pass an array as a parameter with  
> link\_to.
> 
> Just say in index action: @stuff = Model.find(:all)  
> Then in view I have: link\_to and pass the whole array @stuff to the next  
> action.
> 
> Thanks
