I think this is what you are looking for:
order_array = Order.where("filled = 'PENDING' OR (filled = 'SENT' AND due BETWEEN ? AND ?)", Time.zone.now.beginning_of_day, Time.zone.now.end_of_day)
Frage
I wonder if there is Rails magic to avoid searching the database twice in the following situation:
Background: I am searching for orders from a user which are either PENDING or SENT and due today.
Here is the pseudo code:
order_array = Order.where(:filled => pending) || Order.where(:fileld => done, :due => today)
Now the problem is that this searches the database twice. I'd like to do this in one search and would appreciate pointers into how RoR would do it.
Lösung
I think this is what you are looking for:
order_array = Order.where("filled = 'PENDING' OR (filled = 'SENT' AND due BETWEEN ? AND ?)", Time.zone.now.beginning_of_day, Time.zone.now.end_of_day)
Andere Tipps
Try like below chain condition -
Customer.where(:reseller_id => :map_reseller_id).where(:is_deleted_by_reseller => false)