课程/项目--添加成员:用真实姓名搜索用户时,需要在姓和名之间加个空格才可以搜到

This commit is contained in:
sw 2015-04-14 19:50:17 +08:00
parent c60515ac50
commit 81cbb76d78
1 changed files with 2 additions and 1 deletions

View File

@ -42,7 +42,8 @@ class Principal < ActiveRecord::Base
where({})
else
pattern = "%#{q}%"
sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ")
# sql = %w(login firstname lastname mail).map {|column| "LOWER(#{table_name}.#{column}) LIKE LOWER(:p)"}.join(" OR ")
sql= "LOWER(concat(lastname,firstname)) LIKE LOWER(:p) or LOWER(login) LIKE LOWER(:p) or LOWER(mail) LIKE LOWER(:p)"
params = {:p => pattern}
if q =~ /^(.+)\s+(.+)$/
a, b = "#{$1}%", "#{$2}%"