In order to implement inheritance (STI was not ideal), I have
implemented a solution similar to what is described in this post:
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
the distinct attributes for those classes, and a module that contains
shared functionality for the child models. In the DB, there is one table
per class with foreign keys in the "child" tables the parent.
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? Can
I require eager loading of foo_metadata on all foo finds/conditions?
Thanks,
Josh
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---