渴望在ActiveRecord中仅使用一个条件加载多个表

时间:2015-02-08 05:59:04

标签: activerecord

published = Activity.all.eager_load([:podcast, :blog, :chat]).select('podcasts.draft = false')

我希望此代码能够输出所有不是草稿的播客,以及所有博客和聊天内容。相反,它会输出所有内容。

1 个答案:

答案 0 :(得分:0)

如果要过滤未分组的记录,请使用where

published = Activity.where('podcasts.draft = false').eager_load([:podcast, :blog, :chat])