Forum: Ruby on Rails How-to question: form creation / different table update

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.
Bill W. (Guest)
on 2006-03-01 21:35
(Received via mailing list)
I could use some direction.

I need a form to collect information on a user's allergies.  I want to
present them with a form much like the one we fill out when we see a new
doc where you just check-off the things you're allergic to.  When the
form comes back to the controller I want to add a record to a table for
each allergy they've checked.

I was thinking I should create a table with a record for each allergy I
need to present and use that table to generate the form.  But when I get
the form back I don't want to change the data in the table I used to
generate the form, I want to add data to another table.

Could one of you kind people please point me to documentation /
tutorials that might help?  Any directions are very much appreciated.

Anthony G. (Guest)
on 2006-03-02 16:24
What you're describing is a look up table and a join table

@allergies = Allergy.find_all()
use that collection to geneate your drop down menu or what ever..

Create a join table allergies_users
and a HABTM relationship in the User and Allergy models

All this is described in the Agile book...


This topic is locked and can not be replied to.