On 9/8/06, Stedak <steve-9ABl/wz/ABlDNAp5jbHvCA@public.gmane.org>
wrote:>
> How would I set up the controllers so that I can insert a detail record
> with information from the web page and the master record at the same
> time?
>
> For instance if I had a new book entry in the book database I want to
> add a new author record in the author database - assuming the author
> did not exist.
It''s easier than you think.
In general...
# set up the master record ...
# <however you do that> master = Master.find(id), etc.
# set up the detail records...
<however you do THAT>
# associate the 2
master.details << detail
# or, master.details = details
# or, master.details << details
# profit!
if master.save
success
else
error
end
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---