修改用户搜索无法精确搜索的bUG

This commit is contained in:
sw 2014-12-24 09:08:42 +08:00
parent 3caf5c8657
commit b512bc53e9
2 changed files with 4 additions and 4 deletions

View File

@ -377,7 +377,7 @@ class UsersController < ApplicationController
}
scope = User.logged.status(@status)
@search_by = params[:search_by] ? params[:search_by][:id] : 0
scope = scope.like(params[:name],@search_by) if params[:name].present?
scope = scope.like(params[:name],"0") if params[:name].present?
@user_count = scope.count
@user_pages = Paginator.new @user_count, @limit, params['page']
@user_base_tag = params[:id] ? 'base_users':'users_base'

View File

@ -206,11 +206,11 @@ class User < Principal
pattern = "%#{arg.to_s.strip.downcase}%"
#where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern)
if type == "0"
where(" LOWER(login) LIKE :p ", :p => pattern)
where(" LOWER(login) LIKE '#{pattern}' ")
elsif type == "1"
where(" LOWER(concat(lastname, firstname)) LIKE :p ", :p => pattern)
where(" LOWER(concat(lastname, firstname)) LIKE '#{pattern}' ")
else
where(" LOWER(mail) LIKE :p ", :p => pattern)
where(" LOWER(mail) LIKE '#{pattern}' ")
end
end
}