Alternative to STI with eager loading

Joshua Kahn wrote:

has_many :foos, :conditions => "foo_metadata.created_at < #{Time.now}",                  :order => 'foo.bar DESC, foo_metadata.baz'

I can use eager loading to include the foo_metadata relationship, however, this becomes cumbersome and difficult to manage throughout the application. Is there an alternative solution to this problem? Can I require eager loading of foo_metadata on all foo finds/conditions?

You can add an :include => :foo_metadata option to the has_many declaration. Any includes you use in a find with be automatically merged with this.

Unfortunately, use of eager loading does limit how find can be used in some circumstances, and is wasteful if you're only using the fields in the condition. has_many does not however support the :joins option.