/ Published in: Rails
The right and fastest way to have a HABTM checkboxes, railscast #17
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<% for category in Category.find(:all) %> <div> <%= check_box_tag "product[category_ids][]", category.id @product.categories.include?(category) %> </div> <% end %>