Find file
Fetching contributors…
Cannot retrieve contributors at this time
23 lines (14 sloc) 758 Bytes
ActionView helper to render checkboxes with labels for a HABTM assignment in a form.
* Labels have the for attribute set correctly
* Hidden field included so that you can actually delete all of the associations in an update without adjusting your controller
habtm_checkboxes(@organizer, :event_ids, @events, :name)
<%= hidden_field_tag "organizer[event_ids][]", "" %>
<% @events.each do |event| -%>
<%= check_box_tag "organizer[event_ids][]",, @organizer.event_ids.include?(, :id => "organizer_events_id_#{}" %>
<%= label_tag "organizer_events_id_#{}", h( %>
<% end -%>
Copyright (c) 2010 [John Trupiano], released under the MIT license