ActiveRecord OR查询(多个条件)

时间:2016-04-04 15:14:04

标签: ruby-on-rails activerecord

如何在不使用Rails中的SQL字符串的情况下创建ActiveRecord查询,以获得类似的内容:

books = Book.where(author: 1, **from_day: [1,5] or to_day: [1,5]**)

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

books = Book.where(author: 1).where("from_day IN (?) or to_day IN (?)", [1,5],[1,5])