Destroy dependent notifications of a collection (#39429)
This commit is contained in:
@@ -33,6 +33,7 @@ class Collection < ApplicationRecord
|
||||
has_many :accepted_collection_items, -> { accepted }, class_name: 'CollectionItem', inverse_of: :collection # rubocop:disable Rails/HasManyOrHasOneDependent
|
||||
has_many :collection_reports, dependent: :delete_all
|
||||
has_many :accounts, -> { merge(CollectionItem.pending_or_accepted) }, through: :collection_items
|
||||
has_many :notifications, as: :activity, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
validates :name, length: { maximum: 40 }, if: :local?
|
||||
|
||||
@@ -136,7 +136,7 @@ class Notification < ApplicationRecord
|
||||
belongs_to :generated_annual_report, inverse_of: false
|
||||
belongs_to :quote, inverse_of: :notification
|
||||
belongs_to :collection_item, inverse_of: false # TODO: have an inverse?
|
||||
belongs_to :collection, inverse_of: false # TODO: have an inverse?
|
||||
belongs_to :collection, inverse_of: :notifications
|
||||
end
|
||||
|
||||
validates :type, inclusion: { in: TYPES }
|
||||
|
||||
Reference in New Issue
Block a user