diff --git a/app/models/work.rb b/app/models/work.rb index 57ce298..541f766 100644 --- a/app/models/work.rb +++ b/app/models/work.rb @@ -11,12 +11,15 @@ class Work < ApplicationRecord ######################################################################## # ASSOCIATIONS ######################################################################## +# SIDE PAIRIRING ASSOCIATIONS BEGIN + has_many :work_side_pairings, dependent: :destroy has_many :side_pairings, through: :work_side_pairings, source: :relationship +# END SIDE PAIRING ASSOCIATIONS has_many :external_creatorships, as: :creation, dependent: :destroy, inverse_of: :creation has_many :archivists, through: :external_creatorships has_many :external_author_names, through: :external_creatorships, inverse_of: :works @@ -24,15 +27,7 @@ has_many :side_pairings, # we do NOT use dependent => destroy here because we want to destroy chapters in REVERSE order has_many :chapters, inverse_of: :work, autosave: true -#scope :with_side_pairing, ->(relationship_id) { -#joins(:work_side_pairings) -#.where( -#work_side_pairings: { -#relationship_id: relationship_id -#} -#) -#.distinct -#} + has_many :serial_works, dependent: :destroy has_many :series, through: :serial_works