Let’s say I have two pairs of SQL conditions like these:
a = [ "users.accepted = ? AND users.active_at > ?", true, Time.zone.now ]
b = [ "users.accepted = ? AND users.active_at > ?", false, Time.zone.now + 3.days ]
I can use code like User.where(a) to get all rows that satisfy the a condition. How can I use where to get rows that satisfy either a or b conditions? The result should be ActiveRecord::Relation.
There are a couple ways to go about this.
get meta_where or squeel depending upon your rails version. These are really great gems that enhance the Arel behavior of ActiveRecord::Relation.
write sql manually and pass it into the where method as a string. You might have to mess with sql injection more manually, but from your example above I didn’t see any incoming values that were user generated strings.