Forum: Ruby on Rails testing post :action with an array in the parameters

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
15c2efd46957daed9b4b4568802a2885?d=identicon&s=25 stephanie (Guest)
on 2007-06-21 01:37
(Received via mailing list)
Hi,

I have a html form with check boxes. When the user chooses one or more
check boxes, an array is passed as a parameter to the controller.

in html form page...
<input type='checkbox' name='myarray[]' value='<%= value %>' checked/>
<%= name %> <br/>

in controller
params[:myarray] # this in an array of all the values checked

This works great, but I am having trouble replicating the post in my
tests. Does anybody know how to pass an array in a post test?

This gives me a routing error...

post :create, {:myarray => ['value1, 'value2'] }

Thanks,
Stephanie
15c2efd46957daed9b4b4568802a2885?d=identicon&s=25 stephanie (Guest)
on 2007-06-21 02:26
(Received via mailing list)
After further tinkering I realized that is passing the array. The
routing error was within the action, not the creation of the test
post. Sorry for the list traffic.

-Stephanie
This topic is locked and can not be replied to.