You should just be able to do child.parent
--
Jeremy Chase
http://twitter.com/jeremychase
On Tue, Mar 9, 2010 at 12:51 PM, Marnen Laibow-Koser <lists@ruby-forum.com> wrote:
Grary wrote:
> 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?
If you have your associations set up properly, this is automatic.
Best,
--
Marnen Laibow-Koser
http://www.marnen.org
marnen@marnen.org
--
Posted via http://www.ruby-forum.com/.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
No comments:
Post a Comment