Flowdock

Notes posted by greeneggs614

RSS feed
June 14, 2011
1 thank

Set ids when using a collection of values

The trick to getting the helper to populate a unique HTML ID and for rails to recognise a collection is to give the helper a unique ‘name’ and to set the :name symbol to parameter with an array symbol ‘[]’.

<% Cars.each do |c| %>
  <%= check_box_tag "car_ids[#{c.id}]", c.id, :name => "car_ids[]" %>
<% end %>