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?
You should be able to use the
buildmethod:See the has_many api documentation or the Rails Guide for associations for a list of methods available on the collection.