Escaping from ilike

Hello,
I’m try to escape text from ilike but it doesn’t work. when i type ‘%’
it send the request ‘%%%’ so it return every record
Here is the function.
def self.autocomplete(text, options={})
text = ‘%’ + self.sanitize_sql(text.downcase.strip.squeeze(" ") )

  • ‘%’
    self.find(:all, :conditions => [‘name ILIKE ?’,
    text]).collect(&:name)
    end

i even tried with gsub, something like gsub(/([%])/, ‘\\1’) to
escape ‘%’ and '
’ but i’m really familar to this function or regex.

any idea?
regards.