迁移报错的实训

dev_haigong
daiao 6 years ago
parent e46a10749b
commit f8611f90b6

@ -1116,7 +1116,7 @@ class ShixunsController < ApplicationController
apply_record = ApplyAction.where(:container_id => @shixun.id, :container_type => "ApplyShixun") apply_record = ApplyAction.where(:container_id => @shixun.id, :container_type => "ApplyShixun")
apply_record.delete_all if apply_record apply_record.delete_all if apply_record
HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决 HomeworkCommonsShixuns.where(:shixun_id => @shixun).delete_all # 关联删报错,后续解决
@shixun.destroy @shixun.update_attribute(:status, -1)
respond_to do |format| respond_to do |format|
if params[:come_from] == "admin" if params[:come_from] == "admin"
format.html{ redirect_to shixuns_managements_path } format.html{ redirect_to shixuns_managements_path }

@ -73,7 +73,7 @@ class Shixun < ActiveRecord::Base
end end
def fork_identifier 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 end
def get_fork def get_fork

@ -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
Loading…
Cancel
Save