How can I make an 'OR' statement in ActiveRecord?

前端 未结 2 829
暗喜
暗喜 2021-01-03 02:20

I am trying to create an \'OR\' sql statement in ActiveRecord 3, I tried all kinds of variations but can\'t figure it out...

For example I want this query to include

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 02:37

    Try this:

    Post.where("posts.user = ? OR posts.channel_id IN (?)", "mike", ids)
    

提交回复
热议问题