Mongoid中的多条件

amr*_*rnt 1 ruby-on-rails mongoid

我的Thing模型有一系列主题和以下内容.

我想找到所有thingscurrent_user跟随它Topic或它的"用户".

@things = Thing
          .where(:user_id.in => current_user.following.map{ |u| u._id })
          .where(:topic_id.in => current_user.topics.map{ |u| u._id })
Run Code Online (Sandbox Code Playgroud)

这样的事情.但这实际上不起作用.它只返回两个where条件之间常见事物的记录.

我想要的是返回2个where语句找到的所有记录.

谢谢

Jam*_*een 8

.any_of(
  { :user_id.in => current_user.following.map{ |u| u._id } }, 
  { :topic_id.in => current_user.topics.map{ |u| u._id } }
)
Run Code Online (Sandbox Code Playgroud)