-1
published = Activity.all.eager_load([:podcast, :blog, :chat]).select('podcasts.draft = false')
我希望此代碼輸出所有不是草稿的播客,以及所有博客和聊天。相反,它會輸出一切。在ActiveRecord中只使用一個條件加載多個表
published = Activity.all.eager_load([:podcast, :blog, :chat]).select('podcasts.draft = false')
我希望此代碼輸出所有不是草稿的播客,以及所有博客和聊天。相反,它會輸出一切。在ActiveRecord中只使用一個條件加載多個表
使用where
如果要過濾未分組記錄:
published = Activity.where('podcasts.draft = false').eager_load([:podcast, :blog, :chat])