From f8611f90b628bfaf19d2beb224e9f19cd666c877 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Mon, 1 Apr 2019 09:22:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E6=8A=A5=E9=94=99=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E8=AE=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- app/models/shixun.rb | 2 +- .../20190401011345_modify_fork_from_for_shixuns.rb | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20190401011345_modify_fork_from_for_shixuns.rb 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