As the attached screenshot describes, there are three tables. A has multiple Bs and C has multiple Bs. There is no relationship between A and C.
On the circumstance, when finding A's records, is it possible to include B and C?
B can easily be included by A.all(:conditions => { :id => id }, :include => [:B])
.
However, I do not know how to include C even if I googled for many hours.
=====================
rails version: 2.3.5
ruby version: 1.8.7
CodePudding user response:
From looking at https://guides.rubyonrails.org/v2.3/active_record_querying.html#nested-associations-hash my guess would be that the following would work.
A.all(:conditions => { :id => id }, :include => { :B => :C })