修复bug#2270 :forge/course主页--搜索用户无任何作用
This commit is contained in:
parent
3c810a0cee
commit
4b58699ee9
|
@ -383,6 +383,8 @@ 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?
|
||||
@search_by = params[:search_by] ? params[:search_by] : 0
|
||||
|
||||
us = UsersService.new
|
||||
scope = us.search_user params
|
||||
@user_count = scope.count
|
||||
|
|
|
@ -206,10 +206,18 @@ class UsersService
|
|||
}
|
||||
scope = User.logged.status(status)
|
||||
if params[:is_search_assitant].nil?
|
||||
watcher = User.watched_by(params[:user_id])
|
||||
watcher.push(params[:user_id])
|
||||
#modify by yutao 2015/5/18 没有params[:user_id]参数时去掉"id not in (?)"条件(bug:#2270) start
|
||||
#say by yutao: params[:user_id]这个是指谁发起的搜索么? 如果是 这个值貌似应该从session获取 怪怪的赶脚-_-!
|
||||
search_by = params[:search_by] ? params[:search_by] : "0"
|
||||
scope = scope.where("id not in (?)",watcher).like(params[:name],search_by) if params[:name].present?
|
||||
if params[:name].present?
|
||||
if !params[:user_id].nil?
|
||||
watcher = User.watched_by(params[:user_id])
|
||||
watcher.push(params[:user_id])
|
||||
scope = scope.where("id not in (?)",watcher)
|
||||
end
|
||||
scope = scope.like(params[:name],search_by)
|
||||
end
|
||||
#modify by yutao 2015/5/18 没有params[:user_id]参数时去掉"id not in (?)"条件 end
|
||||
else
|
||||
teachers = searchTeacherAndAssistant(Course.find(params[:course_id]))
|
||||
scope = scope.where("id not in (?)",teachers.map{|t| t.user_id}).like(params[:name],search_by) if params[:name].present?
|
||||
|
|
Loading…
Reference in New Issue