Update app/models/work.rb
This commit is contained in:
parent
82a429abd1
commit
a08edd69b9
1 changed files with 4 additions and 9 deletions
|
|
@ -11,12 +11,15 @@ class Work < ApplicationRecord
|
||||||
########################################################################
|
########################################################################
|
||||||
# ASSOCIATIONS
|
# ASSOCIATIONS
|
||||||
########################################################################
|
########################################################################
|
||||||
|
# SIDE PAIRIRING ASSOCIATIONS BEGIN
|
||||||
|
|
||||||
has_many :work_side_pairings,
|
has_many :work_side_pairings,
|
||||||
dependent: :destroy
|
dependent: :destroy
|
||||||
|
|
||||||
has_many :side_pairings,
|
has_many :side_pairings,
|
||||||
through: :work_side_pairings,
|
through: :work_side_pairings,
|
||||||
source: :relationship
|
source: :relationship
|
||||||
|
# END SIDE PAIRING ASSOCIATIONS
|
||||||
has_many :external_creatorships, as: :creation, dependent: :destroy, inverse_of: :creation
|
has_many :external_creatorships, as: :creation, dependent: :destroy, inverse_of: :creation
|
||||||
has_many :archivists, through: :external_creatorships
|
has_many :archivists, through: :external_creatorships
|
||||||
has_many :external_author_names, through: :external_creatorships, inverse_of: :works
|
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
|
# we do NOT use dependent => destroy here because we want to destroy chapters in REVERSE order
|
||||||
has_many :chapters, inverse_of: :work, autosave: true
|
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 :serial_works, dependent: :destroy
|
||||||
has_many :series, through: :serial_works
|
has_many :series, through: :serial_works
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue