postgresql - How do I make a query search in rails case insensitive? -
i have search method in user.rb model
def self.search(query) where("description ?", "%#{query}%") end
but search case sensitive. want make case insensitive. how do that? i'm hoping it's quick fix.
thanks
because using postgresql:
def self.search(query) where("description ilike ?", "%#{query}%") end
just use ilike
instead of like
. like/ilike documentation
if want use =, both sides either upper or lower
Comments
Post a Comment