In Rails, how do you write the ActiveRecord, "where this column's value is not equal to any value in this array of strings"?
I'm trying to move some ruby logic into SQL by rewriting a .reject
method into a .where
.
# old
SomeModel.all.reject{ |sm| some_array.include? sm.x } # works, but is inefficient
# new
SomeModel.where(__________) # what goes here?
EDIT EDIT EDIT
By the way, I was initially having problems because I didn't understand how SQL handles NULL
s in IN
. This SO question explains it nicely.