I have a HABTM relationship between Publications and Categories. In the new and edit views, I have this:
Categories:<br />
<% @categories.each do |c| %>
<%= check_box_tag :category_ids, c.id, @publication.categories.include?(c), :name => 'publication[category_ids]' -%>
<%= "#{c.name}"%>
<% end -%>
The model code:
class Publication < ActiveRecord::Base
has_many :listings
has_many :categories, :through => :listings, :order => "listings.position"
This displays just fine - on update, though, it only saves the last category that is checked (if I check multiple categories, only one is saved), if I don't check any box, it doesn't change what's mapped.