Well, I know how to handle associations from one model (call it ModelA) through the second one (ModelB) to the third one (ModelC). But what if the third one(ModelC) is associated to the fith one(ModelE) trough the 4th (ModelD).
#ModelA
has_many :model_bs
has_many :model_cs, :trough => :model_bs
#ModelC
has_many :model_ds
has_many :model_es, :trough => model_ds
The question is: how can I get the collection of ModelE records, associated with the specific ModelA record trough that chain?
Calling
model_cson an instance ofModelAwill return an array ofmodel_cs. If you then wanted to access all themodel_esyou would need to iterate over the array ofmodel_csand append those results to an array or hash.array2now contains all themodel_eswhose ultimate parent is the originalmodel_a.