Commit ed7a137f23bb320faecb9a4b4ab49045c7bd0df0
1 parent
e1e4ea6d
Exists in
master
and in
19 other branches
Don't allow any updates in Searchkick.callbacks(false) block [skip ci]
Showing
1 changed file
with
5 additions
and
3 deletions
Show diff stats
lib/searchkick/model.rb
@@ -67,14 +67,16 @@ module Searchkick | @@ -67,14 +67,16 @@ module Searchkick | ||
67 | callbacks = options.key?(:callbacks) ? options[:callbacks] : true | 67 | callbacks = options.key?(:callbacks) ? options[:callbacks] : true |
68 | if callbacks | 68 | if callbacks |
69 | if respond_to?(:after_commit) | 69 | if respond_to?(:after_commit) |
70 | - after_commit :reindex, if: -> { Searchkick.callbacks? } | 70 | + after_commit :reindex |
71 | elsif respond_to?(:after_save) | 71 | elsif respond_to?(:after_save) |
72 | - after_save :reindex, if: -> { Searchkick.callbacks? } | ||
73 | - after_destroy :reindex, if: -> { Searchkick.callbacks? } | 72 | + after_save :reindex |
73 | + after_destroy :reindex | ||
74 | end | 74 | end |
75 | end | 75 | end |
76 | 76 | ||
77 | def reindex(method_name = nil, refresh: false, mode: nil) | 77 | def reindex(method_name = nil, refresh: false, mode: nil) |
78 | + return unless Searchkick.callbacks? | ||
79 | + | ||
78 | klass_options = self.class.searchkick_index.options | 80 | klass_options = self.class.searchkick_index.options |
79 | 81 | ||
80 | if mode.nil? | 82 | if mode.nil? |