From 8ae55875165708bec23d081f74a927f99f559626 Mon Sep 17 00:00:00 2001 From: yystopf Date: Wed, 8 Jun 2022 10:37:31 +0800 Subject: [PATCH] fix: search name use strip --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index fa940c29e..bc9808c64 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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)}