Checkbox with has_many


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

class Name < ActiveRecord::Base
belongs_to :user

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’, ‘’, {}, 0, ‘Joe’ %> Joe
<%= check_box ‘user’, ‘’, {}, 0, ‘Bob’ %> Bob
<%= check_box ‘user’, ‘’, {}, 0, ‘Bill’ %> Bill


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs