fix: search name use strip

This commit is contained in:
yystopf 2022-06-08 10:37:31 +08:00
parent 0b543f7dda
commit 8ae5587516
1 changed files with 1 additions and 1 deletions

View File

@ -179,7 +179,7 @@ class User < Owner
scope :active, lambda { where(status: STATUS_ACTIVE) }
scope :like, lambda { |keywords|
sql = "CONCAT(lastname, firstname) LIKE :search OR nickname LIKE :search OR login LIKE :search OR mail LIKE :search OR nickname LIKE :search"
where(sql, :search => "%#{keywords.split(" ").join('|')}%") unless keywords.blank?
where(sql, :search => "%#{keywords.strip}%") unless keywords.blank?
}
scope :simple_select, -> {select(:id, :login, :lastname,:firstname, :nickname, :gitea_uid, :type)}