开发者

How to get non-flagged users

开发者 https://www.devze.com 2023-03-11 12:27 出处:网络
This gets me all 开发者_JS百科users who are flagged: User.joins(:flags) How would I do the opposite of above?Try something like:

This gets me all 开发者_JS百科users who are flagged:

User.joins(:flags)

How would I do the opposite of above?


Try something like:

User.find(:all,
          :joins => 'LEFT JOIN flags ON users.flag_id=flags.id',
          :group => 'users.id',
          :having => 'flags.id IS NULL')
0

精彩评论

暂无评论...
验证码 换一张
取 消