This problem has stumped me for a long time. I figured it was time to
seek expert advice!
Say you have the following models:
class Part < ActiveRecord::Base
has_and_belongs_to_many :model_applications
end
class ModelApplication < ActiveRecord::Base
belongs_to :model
has_and_belongs_to_many :parts
end
class Model < ActiveRecord::Base
belongs_to :make
end
class Make < ActiveRecord::Base
has_many :models
end
The problem I''m having is I''d like to LEFT JOIN :model, and
:make in
addition to :model_applications. For example:
@parts = Part.find(:all, :include => [ :model_applications, :model, :make ])
It seems like :include only works on directly related tables (eg.
:model_applications is directly related to :parts).