# Eager loading with inheritance

**URL:** <https://www.ruby-forum.com/t/eager-loading-with-inheritance/88247>\
**Category:** Rails\
**Created:** [March 9, 2007, 5:01am UTC](https://www.ruby-forum.com/t/eager-loading-with-inheritance/88247 "2007-03-09T05:01:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![josh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/45deac/32.png) [@josh](https://www.ruby-forum.com/u/josh)\
**Post date:** [March 9, 2007, 5:01am UTC](https://www.ruby-forum.com/t/eager-loading-with-inheritance/88247/1 "2007-03-09T05:01:59Z")

</div>

In order to implement inheritance (STI was not ideal), I have  
implemented a solution similar to what is described in this post:  
[Any good alternative to single-table-inheritance? - Rails - Ruby-Forum](http://www.ruby-forum.com/topic/73822#108686). I have one model that  
acts as a parent class with shared attributes, two child models with  
different attributes, and a module that contains shared functionality  
for the child models.

The issue arises in creating associations with other models when it is  
necessary to provide conditions on the association, for example:

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?  
Would composed\_of (or other composition options) be of any help?

Thanks,  
Josh
