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')
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.
Just in case someone needs to do this with ransack:
ransacker :subject_cs, :formatter => proc {|v| v.downcase }, :splat_param => true, :type => :string do
arel_table[:subject].lower
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.