0

I'm new to Rails and I'm using Google Translate to post here. I have a doubt.

I have the following scope: I'm trying to remove the accent from the bank words when performing a search.

In the parameters it already works with parameterize, but how do I query the bank (inside the where) to remove the accent? I'm using postgresql.

Initially I tried to use regex_replace, but apparently it didn't work, could I be applying it wrong?

   scope :filter_occupation, -> (params) {
     params[:occupation].present? ?
       where("lower(regexp_replace(occupation, '[^\w]+','')) LIKE ?",
       # where("lower(occupation) LIKE ?",
         "%#{params[:occupation].parameterize(separator: ' ')}%")
     :
     all
   }
tadman
  • 208,517
  • 23
  • 234
  • 262

0 Answers0