From b512bc53e90196d522470a2780bbe1bbfe5d8e1f Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 24 Dec 2014 09:08:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=97=A0=E6=B3=95=E7=B2=BE=E7=A1=AE=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=9A=84bUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/models/user.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8183ed7ad..56777fd22 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -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' diff --git a/app/models/user.rb b/app/models/user.rb index cae5f1aa2..e966742f1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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 }