Reputation: 53
I want something like this:
<%= f.hidden_field :ids, :multiple => true, :value => array %>
but it's not saving anything. Am I doing anything wrong or is there another way to approach this?
Upvotes: 3
Views: 3972
Reputation: 3268
try this
<% array.each do |a| %>
<%= f.hidden_field :ids, :multiple => true, :value => a %>
<% end %>
some says this wont work in rails 4
<%= f.hidden_field :ids, :multiple => true, :value => a %>
replace that with this incase it wont work for you
<%= f.hidden_field "ids[]", value: a %>
or you can try using hidden_field_tag as well.. if you can access without object
<% array.each do |a| %>
<%= hidden_field_tag "ids[]", a %>
<% end %>
and in controller you can access using this params[:ids]
Upvotes: 1