修复作业列表搜索bug

This commit is contained in:
nieguanghui 2013-11-01 10:48:02 +08:00
parent 775ebc3607
commit 583c022048
1 changed files with 4 additions and 2 deletions

View File

@ -427,11 +427,13 @@ class UsersController < ApplicationController
end
if params[:user].present?
user_temp = User.find_by_sql("select id from users where firstname like '%#{params[:user]}%' or lastname like '%#{params[:user]}%'")
if user_temp.size > 1
activity = Activity.where('user_id in (?)', user_temp).order('id desc')
activity = Activity.where('user_id in (?)', user_temp).where('user_id in (?)', watcher).order('id desc')
elsif user_temp.size == 1
activity = Activity.where('user_id = ?', user_temp).order('id desc')
activity = Activity.where('user_id = ?', user_temp).where('user_id in (?)', watcher).order('id desc')
else
activity = Activity.where("1 = 0")
end