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.
Controller:
@member=Member.find(:all)
if params[:new_member]=nil
@list=[]
@list.push(Member.new)
else
@list=params[‘list’]
@list.push(Member.find(params[:new_member]))
end
View:
Inside a form that redirects to the controller
<%=member.name> <%end%><%=submit_tag(“Add”)%>
<%= hidden_field “list”, @list %> # [1]
[1] Here’s the problem. The error I got is
“undefined method `push’ for {”#<User:
0xb7086210>"=>""}:HashWithIndifferentAccess"
But more important in parameters[error log]:
""list"=>{"#<User:0xb7086210>"=>""}}"
It means that the params[‘list’] value is taken as @list.name [that is
just garbage]
I Hope someone can help me! Thanks!