How-to question: form creation / different table update


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.



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…