Creating a master/detail record in one shot

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.

Thanks!

On 9/8/06, Stedak [email protected] 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 …

master = Master.find(id), etc.

set up the detail records…

associate the 2

master.details << detail

or, master.details = details

or, master.details << details

profit!

if master.save
success
else
error
end