I have a simple DB query that is checking if a particular field does not contain 3x strings:
scope :not_abc, -> {
where.not(name: ['A', 'B', 'C'])
}
The field in question is just a string with no default value, from schema.rb:
t.string "name", limit: 255
The problem is that the query above only returns fields that are non-nil, for example:
Returned objects:
name = ""
OR
name = "<any string NOT A,B,C>"
Ignored objects:
name = nil
OR
name = "A" or "B" or "C"
Is there any way to build a rails query that searches with an array of strings but includes nil values in the results?
What should be returned:
name = nil
OR
name = ""
OR
name = "<any string NOT A,B,C>"
where("name NOT IN (?) OR name = ?" ['A', 'B', 'C'], nil)add this.where.not(name: ['A', 'B', 'C'])OR name = ?has no effect.OR name = ?