Coupon has 3 fields I want to query on:
start_date (Date object),
end_date (Date object) and
I would like to do something like this:
Coupon.where("start_date <= Date.today AND (immortal = true OR end_date >= Date.today)")
But I only make bullshits :/ Please help me!
Regarding this tutorial, your code should work : http://sql.sh/cours/where/and-or (french) Did you have any displayed error message ?
It's OK I found that:
Coupon.where("start_date =< ?", Date.today).where("immortal = ? OR end_date >= ?", true, Date.today) ?
 what about using a method 'active?' in your model
immortal || ( Date.today >= start_date && Date.today <= expiration_date )
Coupon.where( active? )
Be careful I changed the rules ('immortal' here prevails on any start/end date given) and I did not crash-tested this code.
Finally, this works:
Coupon.where("start_date =< ? AND (immortal = ? OR end_date >= ?)", Date.today , true, Date.today)
Thanks to all of you