For demonstration purposes, imagine:
class Content < ActiveRecord::Base; end
class Item < Content; end
class Photo < Item; end
class Collection < Content
has_many :items, :through => :child_containerships,
:source => :child,
:class_name => 'Item'
# imagine the rest of the supporting classes and relationships for this
# association; they were removed for brevity
end
When I access items normally (like Collection.find(1).items) the SQL correctly shows "WHERE contents.type = 'Item' OR contents.type = 'Photo'"
However, when I eagerly load the items - Collection.find(1, :include => :items) - the SQL doesn't contain the subclass. The appropriate place in the ON clause of the JOIN only contains "contents.type = 'Item'". Obviously this screws things up.
(Also, if I don't provide class_name to the association in the first place, it won't filter by STI class at all and only relies on the child_containerships relationship).