HABTM checkboxes


/ Published in: Rails
Save to your folder(s)

The right and fastest way to have a HABTM checkboxes, railscast #17


Copy this code and paste it in your HTML
  1. <% for category in Category.find(:all) %>
  2. <div>
  3. <%= check_box_tag "product[category_ids][]", category.id
  4. @product.categories.include?(category) %>
  5. </div>
  6. <% end %>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.