Reputation: 59
I have this search method in my user.rb model
def self.search(query)
where("description like ?", "%#{query}%")
end
but my search is case sensitive. I want to make it case insensitive. How do I do that? I'm hoping it's a quick fix.
Thanks
Upvotes: 0
Views: 287
Reputation: 5239
Because you are using postgresql:
def self.search(query)
where("description ilike ?", "%#{query}%")
end
Just use ilike
instead of like
. like/ilike documentation
If you want to use =, both sides either UPPER or LOWER
Upvotes: 1