Forum: Ruby on Rails Using same form for two models

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.
5eb7dc9121bd474726f9f5568c9573ed?d=identicon&s=25 Per Djurner (pernod)
on 2006-01-19 14: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?
Be5736b3bc77d526585c1f17b6692520?d=identicon&s=25 koloa (Guest)
on 2006-11-04 07:55
hello,
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 table....is 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.