We Recommend

The Rails Way The Rails Way
Now, for the first time, there’s a comprehensive, authoritative guide to building production-quality software with Rails. Pioneering Rails developer Obie Fernandez and a team of experts illuminate the entire Rails API, along with the Ruby idioms, design approaches, libraries, and plug-ins that make Rails so valuable.


Posted By

bordalix on 07/13/07


Tagged

checkboxes habtm


Versions (?)


HABTM checkboxes


Published in: Rails 


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

  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 

You need to login to post a comment.