Defining a scope which compares a field against an array

Hello,

I am defining the following scope for my model:

class Entry < ActiveRecord::Base

attr_accessible :email, :published, :result_id, :text, :url

belongs_to :result

def self.not_filtered(keywords)

where(['text NOT IN (?)', keywords]) if keywords.any?

end

This is supposed to return only Entries where the Entry.text doesn’t contain any of the keywords.

Example:

entries.not_filtered([“realtor”, “quadplex”, “duplex”, “condo”, “agent”, “broker”])

But somehow this doesn’t exclude the entires which include the keywords in the array.

Is there a way to write that differently? How?

I think squeel (https://github.com/ernie/squeel) is the best way to go:

     Person.where{name.like_any names}
# => SELECT "people".* FROM "people" WHERE (("people"."name" LIKE 'Ernie%' OR "people"."name" LIKE 'Joe%' OR "people"."name" LIKE 'Mary%'))