Thursday, February 10, 2011

active record: create record from parent object...

this is what I mean:

job has many docs. I want to create a doc, I can do:

@doc = Doc.new(params[:doc])

but I'd like to enforce the parent-child relationship, since I already know the job.. something like this:

@job.docs.new(params[:doc])

so that the job_id field gets ignored and only the @job object matters...

does it make any sense?

0 comments:

Post a Comment