diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 6d58fa8a..5c9ef13c 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1368,6 +1368,7 @@ end after_dep = Department.where(:school_id => params[:school_id], :name => department.name).first if after_dep UserExtensions.where(:school_id => params[:applied_id], :department_id => department.id).update_all(:department_id => after_dep.id) + department.apply_add_departments.destroy_all department.destroy else department.apply_add_departments.update_all(:school_id => params[:school_id]) diff --git a/app/models/department.rb b/app/models/department.rb index 4f383bf4..360302f0 100644 --- a/app/models/department.rb +++ b/app/models/department.rb @@ -4,7 +4,7 @@ class Department < ActiveRecord::Base # apply_add_departments 不能关联删除 tidings表有关联 has_many :apply_add_departments has_many :tidings, as: :container, dependent: :destroy - attr_accessible :name, :school_id, :is_auth, :identifier, :is_delete + attr_accessible :name, :school_id, :is_auth, :identifier, :is_delete, :host_count scope :is_active, lambda{where(:is_delete => false)} scope :is_delete, lambda{where(:is_delete => true)}