From 56eb2ebb005b398be86bd0178e45fd19997c1f48 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 9 Dec 2019 21:27:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=8F=AD=E5=AF=BC=E5=87=BA=E6=88=90?= =?UTF-8?q?=E7=BB=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index de24f7a8e..b08ba2dbd 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -1299,8 +1299,10 @@ class CoursesController < ApplicationController begin @all_members = @course.students search = params[:search] ? "#{params[:search].strip}" : "" #用户名或学生学号id搜索 - group_id = params[:group_id] #分班的班级id - @all_members = @all_members.where(course_group_id: group_id.map(&:to_i)) unless group_id.blank? + if params[:group_id].present? + group_ids = params[:group_id].is_a?(String) ? [params[:group_id].to_i] : params[:group_id].map(&:to_i) + @all_members = @all_members.where(course_group_id: group_ids) + end unless search.blank? @all_members = @all_members.joins(user: [:user_extension]).where('concat(users.lastname, users.firstname) like ? or user_extensions.student_id like ?',"%#{search}%","%#{search}%") end