ruby-on-railsruby-on-rails-3oracle-databasecase-sensitivemeta-search

ruby on rails, meta_search and case insensitive oracle


I am using meta_search gem on my rails project. The database is an Oracle database and "like" is case sensitive. Does somebody know how I can create a new condition, or something, for get queries like this:

UPPER(NAME) LIKE UPPER('User Firstname')

Solution

  • meta_search method class - first two code samples. Just instead of :backwards_name rewrite it to be :incasesensitive_name or whatever you want and add such text field to your search form.

    UPPER() is built into Oracle AFAIR, so scope may look like this:

    scope :incasesensitive_name, lambda {|name| where('UPPER(name) LIKE ?', "%#{name.upcase}%")}
    

    Hope it helps.