1
ben gibi bir şey almak için Rails SQL dizesi kullanmadan bir ActiveRecord sorgusu nasıl oluştururum:ActiveRecord OR sorgu (çoklu koşullar)
books = Book.where(author: 1, **from_day: [1,5] or to_day: [1,5]**)
ben gibi bir şey almak için Rails SQL dizesi kullanmadan bir ActiveRecord sorgusu nasıl oluştururum:ActiveRecord OR sorgu (çoklu koşullar)
books = Book.where(author: 1, **from_day: [1,5] or to_day: [1,5]**)
Bu deneyebilirsiniz:
books = Book.where(author: 1).where("from_day IN (?) or to_day IN (?)", [1,5],[1,5])
Sadece netleştirmek için - [1,5] 'ile kastedilen nedir? – jkdev
iki seçenek: 1 veya 5 – Zelenka
[ActiveRecord VEYA sorgu Karma gösteriminin] olası kopyası (http://stackoverflow.com/questions/31096009/activerecord-or-query-hash-notation) – potashin