/ Published in: Rails
Used to create checkboxes to select multiple categories for a post or any other type of applicable situation.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<% for category in Category.find(:all) %> <%= check_box_tag "post[category_ids][]", category.id, @post.categories.include?(category) %> <%= category.name %><br /> <% end %>