Rails ActiveRecord where or clause

后端 未结 4 1445
滥情空心
滥情空心 2020-12-20 16:26

I\'m looking to write an ActiveRecord query and this is what I have below. Unfortunately you can\'t use OR like this. What\'s the best way to execute? category_ids<

4条回答
  •  萌比男神i
    2020-12-20 17:14

    What you want to do is manually write the OR part of the query like this:

    .where("category.id in (#{category_ids.join(',')}) OR category_relationships.category_id in (#{category_ids.join(',')})")

提交回复
热议问题