I have a model that has :
Class Bar < ActiveRecord::Base
#...
belongs_to :foo_A, :class_name => "Foo"
belongs_to :foo_B, :class_name => "Foo"
And I would like to fetch information from table Foo as follows (code will not work):
Bar.joins(:foo_A, :foo_B).select("bars.*, foos_a.name as foo_a_name, foos_b.name as foo_b_name").all
Of course, there's no foos_a or foos_b table... just the foos table.
Is there a way to do it without writing the whole sql query ?
Thanks