From ed7a137f23bb320faecb9a4b4ab49045c7bd0df0 Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 1 Mar 2018 16:36:41 -0800 Subject: [PATCH] Don't allow any updates in Searchkick.callbacks(false) block [skip ci] --- lib/searchkick/model.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/searchkick/model.rb b/lib/searchkick/model.rb index a86e84b..b4dbfcd 100644 --- a/lib/searchkick/model.rb +++ b/lib/searchkick/model.rb @@ -67,14 +67,16 @@ module Searchkick callbacks = options.key?(:callbacks) ? options[:callbacks] : true if callbacks if respond_to?(:after_commit) - after_commit :reindex, if: -> { Searchkick.callbacks? } + after_commit :reindex elsif respond_to?(:after_save) - after_save :reindex, if: -> { Searchkick.callbacks? } - after_destroy :reindex, if: -> { Searchkick.callbacks? } + after_save :reindex + after_destroy :reindex end end def reindex(method_name = nil, refresh: false, mode: nil) + return unless Searchkick.callbacks? + klass_options = self.class.searchkick_index.options if mode.nil? -- libgit2 0.21.0