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