Hello.
Using the “:include”, which generates a “LEFT OUTER JOIN” SQL command,
it is possible to eagerly preload second order data objects (children)
for a given association.
I wanted to know, if it is possible to eagerly preload and cache
third order (or more) data objects, which are little-children or
little-little-children. As I’ve seen. it is possible to add
“LEFT OUTER JOIN” SQL clauses with the needed conditions,
to fetch little-little-children data, but how to do this with
ActiveRecord and its cache?
My models are as follow:
Model Software
-----------------------------
class Software < ActiveRecord::Base
has_many :releases, :exclusively_dependent => true
end
Model Release
-----------------------------
class Release < ActiveRecord::Base
belongs_to :software
has_many :acquisitions, :exclusively_dependent => true
end
Model Acquisition
-----------------------------
class Acquisition < ActiveRecord::Base
belongs_to :release
has_and_belongs_to_many :languages
end
Model Language
-----------------------------
class Language < ActiveRecord::Base
has_and_belongs_to_many :acquisitions
end
Is it possible to find(), or paginate() Software-s, while
eagerly preloading in cache their Release-s, the release
Acquisition-s, and the supported Language-s for those releases?
And how to do it?
Thank to all for your suggestions.