class WorkSidePairing < ApplicationRecord belongs_to :work belongs_to :relationship, class_name: "Relationship" validates :relationship_id, uniqueness: { scope: :work_id } after_create :update_filters after_destroy :update_filters after_create :update_relationship after_destroy :update_relationship def update_filters return unless work && !work.destroyed? work.update_filters end def update_relationship return unless relationship && !relationship.destroyed? relationship.update_tag_cache relationship.enqueue_to_index if relationship.taggings_count < ArchiveConfig.TAGGINGS_COUNT_REINDEX_LIMIT end end