Update app/models/work_side_pairing.rb
This commit is contained in:
parent
092154118b
commit
b7f56fa0ba
1 changed files with 19 additions and 1 deletions
|
|
@ -4,4 +4,22 @@ belongs_to :relationship,
|
||||||
class_name: "Relationship"
|
class_name: "Relationship"
|
||||||
validates :relationship_id,
|
validates :relationship_id,
|
||||||
uniqueness: { scope: :work_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
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue