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.
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.