On 11 May 2010 16:05, dino d. <[email protected]> wrote: > hi - > > if i have > > A has_many B > A has_many C through B > > Is there any way to retrieve the B attributes once I have a C object?
Assuming that you also have B has_many C C belongs_to B then if you have a C in @c you can say @c.b Colin > > For example: > > class User < ... > > has_many :friend_links > has_many :friends, :through => :friend_links, :class => User > ... > > friends = user.friends > for f in friends > link = f.friend_link #i want to get the through object because i > store some metrics here > > is this possible? i realize i can just ignore the through and just > grab the friend_links directly, but i have various types of friends, > some are borne of friend_links, others have a different genesis, and > i'd like to just treat them in one fell swoop, and if one of them > happens to be born of a through, i'll do one thing, but otherwise, > i'll do something else. > > thanks for any help, > dino > > -- > 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. > > -- 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.

