Forum: Ruby on Rails Form - Tick boxes in related table

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
mikej (Guest)
on 2009-04-21 16:47
(Received via mailing list)
Sure this one is solved somewhere, but couldn't find it.

I have a table which has a related table (has many through).  I wish
to choose 1 or more items in the related table with a check box.  For
example, if I had a table with group one, group two and group three
and a list of clients.  I would like to have a form so that given a
client, (in the edit client form), I can assign a client to one or
more groups.

How would I construct a form to achieve this using a reasonable
succinct controller?

Many thanks,

Mike
Andrew T. (Guest)
on 2009-04-21 16:53
(Received via mailing list)
On Tue, Apr 21, 2009 at 2:46 PM, mikej <removed_email_address@domain.invalid> 
wrote:
> How would I construct a form to achieve this using a reasonable
> succinct controller?
>
> Many thanks,
>
> Mike

Have a look at fields_for which you can use for linked models
http://api.rubyonrails.org/classes/ActionView/Help...

There is also Nested Object Forms in Rails 2.3
http://guides.rubyonrails.org/2_3_release_notes.ht...

Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

"I have never let my schooling interfere with my education" - Mark Twain
This topic is locked and can not be replied to.