Forum: Ruby on Rails Using same form for two models

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.
Per D. (Guest)
on 2006-01-19 15:54
Hi, this is probably easy but I can't find any good examples of it.
I have 2 classes, Person and EmailAddress (one person has many
email_addresses). How can I create a form on which you can add one
person and multiple email addresses to the database?

I want to avoid creating two forms.

Preferably it should also do validation so that a person always has at
least one email address.

Any ideas or links to good tutorials on this anyone?
koloa (Guest)
on 2006-11-04 08:55
i am trying to do the same thing..

is it possible to pass 2 hashes, one for each table to update?

for example i have a form that is composed of recipe fields and i have a
file field that gets saved to my pictures there a way that i
can pass the fields that make up the recipe table to my controler where
all i have to do is a '.save' on a new model and the continue on to
process the image?
This topic is locked and can not be replied to.