diff --git a/app/models/education/program.rb b/app/models/education/program.rb index a6a96da035948f47da45fd47e846fa88a84ea7a6..48d81765c55fa7a6318005ee2a47055701d54f6f 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -59,6 +59,8 @@ class Education::Program < ApplicationRecord include WithInheritance include WithPosition include WithBlocks + include WithSchools + include WithDiploma include WithAlumni include WithWebsites include WithTeam @@ -88,16 +90,6 @@ class Education::Program < ApplicationRecord foreign_key: :parent_id, dependent: :destroy - belongs_to :diploma, - class_name: 'Education::Diploma', - optional: true - - has_and_belongs_to_many :schools, - class_name: 'Education::School', - join_table: 'education_programs_schools', - foreign_key: 'education_program_id', - association_foreign_key: 'education_school_id' - # Deprecated, now in diploma enum level: { not_applicable: 0, diff --git a/app/models/education/program/with_diploma.rb b/app/models/education/program/with_diploma.rb new file mode 100644 index 0000000000000000000000000000000000000000..41e3829fc3f170e721959fb1ed8b5b5ea899c6dd --- /dev/null +++ b/app/models/education/program/with_diploma.rb @@ -0,0 +1,9 @@ +module Education::Program::WithDiploma + extend ActiveSupport::Concern + + included do + belongs_to :diploma, + class_name: 'Education::Diploma', + optional: true + end +end diff --git a/app/models/education/program/with_schools.rb b/app/models/education/program/with_schools.rb new file mode 100644 index 0000000000000000000000000000000000000000..c1f2a9032996fee311448dd98032ed144b23c74f --- /dev/null +++ b/app/models/education/program/with_schools.rb @@ -0,0 +1,11 @@ +module Education::Program::WithSchools + extend ActiveSupport::Concern + + included do + has_and_belongs_to_many :schools, + class_name: 'Education::School', + join_table: 'education_programs_schools', + foreign_key: 'education_program_id', + association_foreign_key: 'education_school_id' + end +end diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 8902cb9613fb08eca9fd9074b806c3469d32d87c..a44a083c57a92dc93765c65fd864de704f11d2bf 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -26,8 +26,8 @@ class Education::School < ApplicationRecord include WithGit include Aboutable + include WithPrograms # must come before WithAlumni and WithTeam include WithTeam - include WithPrograms # must come before WithAlumni include WithAlumni belongs_to :university