diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 2f07b182..d91ec474 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -1116,7 +1116,7 @@ class ShixunsController < ApplicationController apply_record = ApplyAction.where(:container_id => @shixun.id, :container_type => "ApplyShixun") apply_record.delete_all if apply_record HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决 - @shixun.destroy + @shixun.update_attribute(:status, -1) respond_to do |format| if params[:come_from] == "admin" format.html{ redirect_to shixuns_managements_path } diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 0a7fff62..6ab98172 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -73,7 +73,7 @@ class Shixun < ActiveRecord::Base end def fork_identifier - self.fork_from.nil? ? "--" : Shixun.find(self.fork_from).try(:identifier) + self.fork_from.nil? ? "--" : Shixun.where(id: self.fork_from).first.try(:identifier) end def get_fork diff --git a/db/migrate/20190401011345_modify_fork_from_for_shixuns.rb b/db/migrate/20190401011345_modify_fork_from_for_shixuns.rb new file mode 100644 index 00000000..98dc7c1e --- /dev/null +++ b/db/migrate/20190401011345_modify_fork_from_for_shixuns.rb @@ -0,0 +1,11 @@ +class ModifyForkFromForShixuns < ActiveRecord::Migration + def up + shixuns = Shixun.where(:fork_from => 1933) + shixuns.each do |shixun| + shixun.update_attribute(:fork_from, nil) + end + end + + def down + end +end