Tag: eager

Ruby on Rails ::包含与子模型的多态关联

使用多态关联时,是否可以在仅存在于某些类型中的子模型上运行包含? 例: class Container belongs_to :contents, :polymorphic => true end class Food has_one :container belongs_to :expiration end class Things has_one :container end 在视图中我将要做的事情如下: 因此,当我加载c时,我想急切加载到期,因为我知道我将需要最后一个。 有没有办法这样做? 只定义一个常规:include得到我的错误,因为并非所有封闭类型都有子模型到期。