From 7af137c46b6a34380e56e363ca096e319698e917 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Tue, 15 Dec 2015 22:48:44 -0800 Subject: [PATCH] Always add callbacks for bulk updates --- README.md | 2 +- lib/searchkick/model.rb | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4971e2b..aa5a583 100644 --- a/README.md +++ b/README.md @@ -406,7 +406,7 @@ There are three strategies for keeping the index synced with your database. end ``` -For better performance, you can also do bulk updates. [master] +You can also do bulk updates. [master] ```ruby Searchkick.callbacks(:bulk) do diff --git a/lib/searchkick/model.rb b/lib/searchkick/model.rb index 2172225..fc39d9d 100644 --- a/lib/searchkick/model.rb +++ b/lib/searchkick/model.rb @@ -70,14 +70,12 @@ module Searchkick end extend Searchkick::Reindex # legacy for Searchjoy - if callbacks - callback_name = callbacks == :async ? :reindex_async : :reindex - if respond_to?(:after_commit) - after_commit callback_name, if: proc { self.class.search_callbacks? } - else - after_save callback_name, if: proc { self.class.search_callbacks? } - after_destroy callback_name, if: proc { self.class.search_callbacks? } - end + callback_name = callbacks == :async ? :reindex_async : :reindex + if respond_to?(:after_commit) + after_commit callback_name, if: proc { self.class.search_callbacks? } + else + after_save callback_name, if: proc { self.class.search_callbacks? } + after_destroy callback_name, if: proc { self.class.search_callbacks? } end def reindex -- libgit2 0.21.0