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

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.
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2006-03-01 20: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.

Thanks,
Bill
F59329dc91cba06600ff65c85fd3e93c?d=identicon&s=25 Anthony Green (acgreen)
on 2006-03-02 15: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...

Best

_tony
This topic is locked and can not be replied to.