From 51228e929b07d8acdbfb4a2c4cdfd0c9a8404a1b Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Fri, 29 Jun 2018 14:26:31 -0400 Subject: [PATCH] Remove user from algolia index before destroy (#524) --- app/models/user.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index 272b210af..8b27444db 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -87,6 +87,7 @@ class User < ApplicationRecord before_validation :set_username before_validation :downcase_email before_validation :check_for_username_change + before_destroy :remove_from_algolia_index algoliasearch per_environment: true, enqueue: :trigger_delayed_index do attribute :name @@ -455,4 +456,8 @@ class User < ApplicationRecord score = (((articles_count + comments_count + reactions_count) * 10) + tag_keywords_for_search.size) * reputation_modifier * followers_count score.to_i end + + def remove_from_algolia_index + remove_from_index! + end end