From d8621fc366df1fb7141373d7bcda556ce9055185 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 24 Jun 2019 14:58:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 3 +-- .../courses/get_historical_course_students.json.jbuilder | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1bf81e87b..253bafa48 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -739,8 +739,6 @@ class CoursesController < ApplicationController # 获取历史课堂,即用户管理的所有课堂以及课堂下的分班(去除当前课堂) def get_historical_courses - user_id = current_user.id - @courses = Course.where.not(id: @course.id).joins(:course_members). where(is_delete: 0, course_members: {user_id: current_user.id, role: %i[CREATOR PROFESSOR ASSISTANT_PROFESSOR]}).includes(:course_groups) # @courses = Course.includes(:course_groups).where(id: current_user.course_members, is_delete: 0) @@ -756,6 +754,7 @@ class CoursesController < ApplicationController @students = @students.where(course_group_id: course_group_id) end + @students = @students.includes(user: [user_extension: :school]) @students_count = @students.size end diff --git a/app/views/courses/get_historical_course_students.json.jbuilder b/app/views/courses/get_historical_course_students.json.jbuilder index 8dc4e22ce..be58ff06a 100644 --- a/app/views/courses/get_historical_course_students.json.jbuilder +++ b/app/views/courses/get_historical_course_students.json.jbuilder @@ -2,8 +2,8 @@ json.students do json.array! @students do |student| json.user_id student.user_id json.name student.user.real_name - json.student_id student.user.user_extension.try(:student_id) - json.school_name student.user.user_extension.school.try(:name) + json.student_id student.user.student_id + json.school_name student.user.school_name end end json.students_count @students_count \ No newline at end of file