# How to pass an array IN via GET?

**URL:** <https://www.ruby-forum.com/t/how-to-pass-an-array-in-via-get/137987>\
**Category:** Rails\
**Created:** [May 19, 2008, 10:17am UTC](https://www.ruby-forum.com/t/how-to-pass-an-array-in-via-get/137987 "2008-05-19T10:17:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael\_teter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@michael\_teter](https://www.ruby-forum.com/u/michael_teter)\
**Post date:** [May 19, 2008, 10:17am UTC](https://www.ruby-forum.com/t/how-to-pass-an-array-in-via-get/137987/1 "2008-05-19T10:17:40Z")

</div>

Howdy.

I’m not sure what the right way to do this is. I basically need to  
pass an array in via GET to my controller action.

For a little background, here’s what’s going on from the user’s  
perspective:

User clicks some checkboxes in my YUI DataTable, thereby marking some  
rows.  
User then clicks something that causes me to gather up a list of the  
selected items, then set those as a new request for another DataTable.

My controller gets these request params, builds a conditions list, and  
fetches records from my model.

For example, my URL would be something like this:  
/my\_controller/my\_action?group=users&limits=dog,cat,bird

Then in my\_action(), I want to use params[:limits] in conjunction  
with  
my\_model.find(:all, :conditions =\> { [animal in (?)],  
params[:limits] } )

(My syntax may be off in my example, but hopefully my goal is clear.)

Thanks!

---

<div class="post-metadata">

**Author:** ![michael\_teter](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/e47c2d/32.png) [@michael\_teter](https://www.ruby-forum.com/u/michael_teter)\
**Post date:** [May 19, 2008, 4:39pm UTC](https://www.ruby-forum.com/t/how-to-pass-an-array-in-via-get/137987/2 "2008-05-19T16:39:40Z")

</div>

Sure, it’s easy. Just append your parameter with empty brackets ([]):

\<%= check\_box\_tag ‘limit[]’, ‘dog’ %\>  
\<%= check\_box\_tag ‘limit[]’, ‘cat’ %\>

Your URL will end up looking like:

/my\_controller/my\_action?group=users&limits[]=dog&limits[]=cat&limits[]=bird

And params[:limit] will be an array.

Brandon

On Mon, May 19, 2008 at 3:17 AM, michael\_teter [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
