From fee7e10b8abf4ef7bc5c33833ca3f6f5dd89dcd3 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Wed, 18 May 2022 07:28:03 +0200 Subject: [PATCH] fix order --- app/models/education/program.rb | 12 ++---------- app/models/education/program/with_diploma.rb | 9 +++++++++ app/models/education/program/with_schools.rb | 11 +++++++++++ app/models/education/school.rb | 2 +- 4 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 app/models/education/program/with_diploma.rb create mode 100644 app/models/education/program/with_schools.rb diff --git a/app/models/education/program.rb b/app/models/education/program.rb index a6a96da03..48d81765c 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 000000000..41e3829fc --- /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 000000000..c1f2a9032 --- /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 8902cb961..a44a083c5 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 -- GitLab