Make LIKE searches case-insensitive also on PgSQL

This commit is contained in:
Jyri-Petteri Paloposki 2020-09-05 01:24:23 +03:00
parent e89511aec8
commit bbb9fc8809
7 changed files with 21 additions and 11 deletions

View file

@ -11,8 +11,8 @@ class Project < ApplicationRecord
scope :completed, -> { where state: 'completed' }
scope :uncompleted, -> { where("NOT(state = ?)", 'completed') }
scope :with_name_or_description, lambda { |body| where("name LIKE ? OR description LIKE ?", body, body) }
scope :with_namepart, lambda { |body| where("name LIKE ?", body + '%') }
scope :with_name_or_description, lambda { |body| where("name " + Common.like_operator + " ? OR description " + Common.like_operator + " ?", body, body) }
scope :with_namepart, lambda { |body| where("name " + Common.like_operator + " ?", body + '%') }
before_create :set_last_reviewed_now