diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index d2c9f88d2..4ce1d7487 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -922,14 +922,16 @@ class CoursesController < ApplicationController school_name = params[:school_name] # REDO:Extension - @users = User.joins(user_extension: :school) - .where("CONCAT(users.lastname, users.firstname) like ? and schools.name like ?", "%#{name}%", "%#{school_name}%") + @users = User.where(status: User::STATUS_ACTIVE) + @users = @users.where("concat(users.lastname, users.firstname) like '%#{name}%'") if name.present? + # REDO:Extension + @users = @users.joins(user_extension: :school).where("schools.name like '%#{school_name}%'") if school_name.present? @users_count = @users.size limit = params[:limit] || 20 page = params[:page] || 1 - @users = @users.page(page).per(limit) + @users = @users.includes(user_extension: :school).page(page).per(limit) end # 申请加入课堂 diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 8a120d6bd..07107b91f 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -890,9 +890,10 @@ class ShixunsController < ApplicationController user_name = "%#{params[:user_name].to_s.strip}%" school_name = "%#{params[:school_name].to_s.strip}%" if user_name.present? || school_name.present? - @users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND - (LOWER(concat(users.lastname, users.firstname)) LIKE ? or users.phone like ?) - AND LOWER(schools.name) LIKE ?", user_name, user_name, school_name) + @users = User.where("users.id not in #{member_ids} AND users.status = 1 AND + (LOWER(concat(users.lastname, users.firstname)) LIKE ? or users.phone like ?)", + user_name, user_name) + @users = @users.joins(user_extension: :school).where("schools.name like '%#{school_name}%'") if params[:school_name].present? else @users = User.none end