Index crop as well on photo changes

This commit is contained in:
Brenda Wallace
2019-12-21 09:36:52 +13:00
parent b4afefcb85
commit cae9fffea6
3 changed files with 14 additions and 2 deletions

View File

@@ -77,6 +77,9 @@ class Garden < ApplicationRecord
end
end
def reindex
end
protected
def strip_blanks

View File

@@ -10,8 +10,8 @@ class PhotoAssociation < ApplicationRecord
##
## Triggers
before_save :set_crop
after_create { |record| record.photographable.reindex }
after_destroy { |record| record.photographable.reindex }
after_create :reindex
after_destroy :reindex
def item
photographable
@@ -31,6 +31,12 @@ class PhotoAssociation < ApplicationRecord
private
def reindex
photographable.reindex
crop&.reindex
true
end
def photo_and_item_have_same_owner
return unless photographable_type != 'Crop'

View File

@@ -57,6 +57,9 @@ class Post < ApplicationRecord
subject
end
def reindex
end
private
def update_crop_posts_association