mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-11 00:10:35 -07:00
school merging tool
This commit is contained in:
parent
bf382b4638
commit
06e733d125
1 changed files with 11 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ class School < ApplicationRecord
|
|||
belongs_to :district
|
||||
has_many :recipients, dependent: :destroy
|
||||
has_many :school_categories, dependent: :destroy
|
||||
has_many :user_schools, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
|
|
@ -12,4 +13,14 @@ class School < ApplicationRecord
|
|||
include FriendlyId
|
||||
friendly_id :name, :use => [:slugged]
|
||||
|
||||
def merge_into(school)
|
||||
puts "Merging #{name} (#{id}) in to #{school.name} (#{school.id})"
|
||||
schedules.update_all(school: school)
|
||||
recipient_lists.update_all(school: school)
|
||||
recipients.update_all(school: school)
|
||||
school_categories.update_all(school: school)
|
||||
user_schools.update_all(school: school)
|
||||
destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue