Forum: Ruby on Rails Send a collection from view to controller

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Hiro (Guest)
on 2009-03-26 19:21
(Received via mailing list)
Hi everybody,

Maybe this is a sort of newbie question but I've been trying to solve
it for several days without a solution.

Basically what I want to do is to pass a collection from the view to
my controller. I paste here the relevant part of both.



if params[:new_member]=nil


Inside a form that redirects to the controller

<select name="new_member">
   <removed_email_address@domain.invalid do |member|%>
     <option value="<>" ><></option>


<%= hidden_field "list", @list %> # [1]

[1] Here's the problem. The error I got is

   "undefined method `push' for {"#<User:

But more important in parameters[error log]:


It means that the params['list'] value is taken as [that is
just garbage]

I Hope someone can help me! Thanks!
Phillip (Guest)
on 2009-03-27 15:54
(Received via mailing list)
First, the comparison between params[:new_member] and nil should use
     if nil == params[:new_member]
Hiro (Guest)
on 2009-03-27 17:50
(Received via mailing list)
On Mar 27, 8:53 am, Phillip <p...@phillip> wrote:
> First, the comparison between params[:new_member] and nil should use
> "=="
>      if nil == params[:new_member]

Yes you're right It was a typing error here in the post. But I still
have this problem I hope so can help me.
Colin L. (Guest)
on 2009-03-27 18:01
(Received via mailing list)
Have a look in the log to see what the parameters are, particularly
params[:list].  I think your code is assuming it is an array but the
suggests otherwise.  Also have a look in the debugger to what is what.
the source of the web page may be informative.

2009/3/27 Hiro <removed_email_address@domain.invalid>
This topic is locked and can not be replied to.