I'm trying to make a general query to my navbar that will check if a record containing any of the given values in any of it's fields can be found.
This is the query in my model:
def self.basic_search(*keywords)
where("specialties %% ARRAY[:k] or treatments && ARRAY[:k]::varchar[] or
neighborhood = ANY(ARRAY[:k]) or name ~ ANY(ARRAY[:k])", k: keywords)
end
And in my controller I'm passing the keywords.split(' ') arguments to this function.
I'm getting an TypeError in my controller that states 'can't quote Array'.
How would I make this query?
I tried change my arrays to match ARRAY[:k]::varchar[] following the Active Record and PostgreSQL - Ruby on Rails Guide but it didn't seem to work.