Forum: Ruby on Rails checkbox with has_many

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4098ef08ed2ee3eabeb0ddf0ec03f783?d=identicon&s=25 Frank Kim (Guest)
on 2006-04-21 03:20
(Received via mailing list)

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 topic is locked and can not be replied to.