how would I do this in Arel ( this AND this) OR ( this AND this)
Context is rails 3.0.7
Mike's answer was basically what you're looking for
class Model < ActiveRecord::Base
def self.this_or_that(a1, a2, a3, a4)
t = Model.arel_table
q1 = t[:a].eq(a1).and(t[:b].eq(a2))
q2 = t[:c].eq(a3).and(t[:d].eq(a4))
where(q1.or(q2))
end
end
some slides I put together on Arel
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With