Rails 4 – checkboxes for has_and_belongs_to_many association

This is all you need to do for the form: Don’t do it manually when there is a built in helper.

<%= form_for @kennel do |f| %>
  <%= f.collection_check_boxes(:handler_ids, Handler.all, :id, :to_s) %>
<% end %>

Leave a Comment