It depends on what you configured as relations between those objects :
I guess you might have something like that :
class Tom < ...(whatever ActiveRecord)
:has_many :harries
:has_many :dicks, :througt => :harries
end
class Dick< ...(whatever ActiveRecord)
:has_many :harries
:has_many :toms, :througt => :harries
end
class Harry < ...(whatever ActiveRecord)
:belongs_to :tom
:belongs_to :dick
end
(I'm not really sure of the correctness of what is written but it's
not the point)
Let's assume that migrations are ok
So what's up @tom, let's say @tom is defined as you proposed
@tom= Tom.find(1)
now you can access the dicks of @tom (haha!!) like this
@tom.dicks
so if you want a specified one, you can do something like that
@tom.dicks[42] # it will return the 42 Dick instance of the Array
represented in @tom.dicks
As this one is an Dick instance, you still have access to his harries,
like this
@tom.dicks[42].harries
And if you want a specific Harry instance, you may try something like
the following
Harry.find(:first, :conditions => [ "tom_id = ? AND dick_id = ? ", 1,
@tom.dicks[42].id])
Having declared @tom= Tom.find(1), you can access @tom.harries which
is an array of Harry object where tom_id = 1.
I though you want to access directly to the related dicks of @tom.