Ruby on Rails: :include on a polymorphic association with submodels
问题 When working with a polymorphic association, is it possible to run an include on submodels that are only present in some types? Example: class Container belongs_to :contents, :polymorphic => true end class Food has_one :container belongs_to :expiration end class Things has_one :container end In the view I'm going to want to do something like: <% c = Containers.all %> <% if c.class == Food %> <%= food.expiration %> <% end %> Therefore, I'd like to eager load the expirations when I load up c,