2016-04-04 22 views
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]**) 
+0

Sadece netleştirmek için - [1,5] 'ile kastedilen nedir? – jkdev

+0

iki seçenek: 1 veya 5 – Zelenka

+0

[ActiveRecord VEYA sorgu Karma gösteriminin] olası kopyası (http://stackoverflow.com/questions/31096009/activerecord-or-query-hash-notation) – potashin

cevap

2

Bu deneyebilirsiniz:

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