I want to find a record by doing something like this
@something = Model.where(X=1 OR Y=1)
But all the things I try don’t work. This should be easy but I can’t find the solution anywhere.
EDIT: To be more specific I am trying to find all records where X is 1 and Y is 1.
Which set here do you want:
If you want 3 only:
Model.where(:x => 1, :y => 1)If you want 1, 2, and 3:
tab=Model.arel_table; Model.where(tab[:x].eq(1).or(tab[:y].eq(1)))Or even:
Model.where(["x=? OR y=?",1,1])if your OR statements aren’t complicated.