How to pass an array IN via GET?


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

User clicks some checkboxes in my YUI DataTable, thereby marking some
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:

Then in my_action(), I want to use params[:limits] in conjunction
my_model.find(:all, :conditions => { [animal in (?)],
params[:limits] } )

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


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:


And params[:limit] will be an array.


On Mon, May 19, 2008 at 3:17 AM, michael_teter [email protected]