开发者

How to get non-flagged users

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜