Checkbox with has_many


#1

Hi,

How do I set up a checkbox to use a record with a has_many field?

For example, say I have a User which is an Active Record Model. And
say it has many names.

class User < ActiveRecord::Base
has_many :names
end

class Name < ActiveRecord::Base
belongs_to :user
end

Say I want to update this user and I want checkboxes that give a
choice between different names. How would I do that?

I would want to do something like this:

<%= check_box ‘user’, ‘names.name’, {}, 0, ‘Joe’ %> Joe
<%= check_box ‘user’, ‘names.name’, {}, 0, ‘Bob’ %> Bob
<%= check_box ‘user’, ‘names.name’, {}, 0, ‘Bill’ %> Bill

Thanks,
Frank