Hi,
I am having trouble with eager loading in my app. It used to work all
the
time, but since upgrading to rails 2.0.2, and now rails 2.1, it doesn’t
work
with many of my queries. For example, this find is loaded eagerly:
@release = Release.find_by_url(params[:id],
:include => [{:artist => :artist_images}, {:songs => :track},
:collection, :hard_products, :release_images, :label],
:conditions => [“labels.name=? OR labels.name=? OR
labels.name=?”,
“Alien8 Recordings”, “Fancy”, “Substractif”])
but this find is not (and it is a simpler query):
@release = Release.find_by_url(params[:id],
:include => [{:songs => :track}, :collection, :hard_products])
FYI, here’s my model relationships:
class Release < ActiveRecord::Base
belongs_to :artist
belongs_to :label
has_many :release_images, :dependent => :destroy
has_many :hard_products
has_many :songs
has_one :collection
end
class Song < Product
belongs_to :release
has_one :track, :dependent => :destroy
end
class Track < ActiveRecord::Base
belongs_to :song
belongs_to :collection
end
class Collection < Product
has_many :tracks
belongs_to :release
end
Does anyone know how to force rails to load eagerly?