diff --git a/app/controllers/admins/laboratory_subjects_controller.rb b/app/controllers/admins/laboratory_subjects_controller.rb index d552b006e..c09697c7e 100644 --- a/app/controllers/admins/laboratory_subjects_controller.rb +++ b/app/controllers/admins/laboratory_subjects_controller.rb @@ -17,11 +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.destroy_all - current_subject.destroy! - - render_delete_success + 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 end diff --git a/app/models/shixun_tag_repertoire.rb b/app/models/shixun_tag_repertoire.rb index 6cb311f7a..afd956350 100644 --- a/app/models/shixun_tag_repertoire.rb +++ b/app/models/shixun_tag_repertoire.rb @@ -3,5 +3,5 @@ class ShixunTagRepertoire < ApplicationRecord belongs_to :tag_repertoire has_many :memos, :through => :memo_tag_repertoires - has_many :memo_tag_repertoires, :dependent => :destroy + # has_many :memo_tag_repertoires, :dependent => :destroy end