From 500d0761eb66e6a6deaee6702f6cfb5a090896d8 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 20 Aug 2019 14:33:38 +0800 Subject: [PATCH 1/2] tiaoz --- app/controllers/shixuns_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 4e3b206e2..bfd386e1c 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -564,7 +564,7 @@ class ShixunsController < ApplicationController # 如果该实训是金课中的实训,则将当前用户加入到当期开课的课堂 if StageShixun.exists?(shixun_id: @shixun.id, subject_id: Subject.where(excellent: 1)) - subject = Subject.where(id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id), excellent: 1).take(1) + subject = Subject.find_by(id: StageShixun.where(shixun_id: @shixun.id).pluck(:subject_id), excellent: 1) course = subject.courses.where("start_date is not null and start_date <= '#{Date.today}' and end_date is not null and end_date >= '#{Date.today}'").take if course.present? && !CourseMember.exists?(course_id: course.id, user_id: current_user.id) # 为了不影响后续操作,用create而不是create! From 300996b0d7d89006797a66b18376e3c34900cca7 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Tue, 20 Aug 2019 14:49:42 +0800 Subject: [PATCH 2/2] tiaoz --- app/controllers/courses_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index d97c26127..591494141 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -152,7 +152,7 @@ class CoursesController < ApplicationController end rescue => e uid_logger_error(e.message) - tip_exception("课堂创建失败!") + tip_exception(e.message) raise ActiveRecord::Rollback end end