mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-19 14:26:14 -04:00
Index crop as well on photo changes
This commit is contained in:
@@ -77,6 +77,9 @@ class Garden < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def reindex
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def strip_blanks
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -57,6 +57,9 @@ class Post < ApplicationRecord
|
||||
subject
|
||||
end
|
||||
|
||||
def reindex
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_crop_posts_association
|
||||
|
||||
Reference in New Issue
Block a user