From 07c117216dd18d91bda5caa66d8f1ebf60dc31c0 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 28 Nov 2019 20:08:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=B7=B5=E8=AF=BE=E7=A8=8B=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admins/laboratory_subjects_controller.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/controllers/admins/laboratory_subjects_controller.rb b/app/controllers/admins/laboratory_subjects_controller.rb index f25a072a3..c09697c7e 100644 --- a/app/controllers/admins/laboratory_subjects_controller.rb +++ b/app/controllers/admins/laboratory_subjects_controller.rb @@ -17,13 +17,15 @@ class Admins::LaboratorySubjectsController < Admins::BaseController def destroy return render_js_error('不能删除自建课程', type: :notify) if current_laboratory_subject.ownership? - current_subject = current_laboratory_subject.subject - current_subject.shixuns.each do |shixun| - shixun.destroy! + ActiveRecord::Base.transaction do + current_subject = current_laboratory_subject.subject + current_subject.shixuns.each do |shixun| + shixun.destroy! + end + current_subject.destroy! + + render_delete_success end - current_subject.destroy! - - render_delete_success end