Ruby on Rails Thursday, December 1, 2011

You want to use Nested Associations, which are covered here:

http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html

On Dec 1, 12:28 am, chandrakant jain <ckjai...@gmail.com> wrote:
> Hi all
>
> I am using four models  user, member, unit, society
> I have linked member, unit and society through member_property table
> user has one to one association with member while all other models
> have many to many association.
>
> How do I link user to member,  and user to unit through member
>
> i wanted something like
>
>         <%= @user.member.unit.unit_number %></p>
>
> Can someone guide how to achieve this

--
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