Hi,
I have controllers for two models between which there exists a
belongs_to/has_one relationship.
How do I reference the parent model object in the child controller so
that I can later recover the child object in the parent controller,
i.e., create and "attach" the child to the parent model for later
recovery?
I would have guessed it was something like as follows:
class ChildController...
def create
@parent = ParentModel.find(params[:id]) # How to get "current"
parent from database?
@parent.child = ChildModel.new(params[:child])
...
Any thoughts?
Grary
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.