Can access the through attributes from the many with has_many through?

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?

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

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