Commit 79d36e86056b548e46299b5c27200ce1d05dff97
1 parent
e27e8c8c
Exists in
master
and in
21 other branches
Added reindex conditionally to docs
Showing
1 changed file
with
12 additions
and
0 deletions
Show diff stats
README.md
@@ -643,6 +643,18 @@ class Product < ActiveRecord::Base | @@ -643,6 +643,18 @@ class Product < ActiveRecord::Base | ||
643 | end | 643 | end |
644 | ``` | 644 | ``` |
645 | 645 | ||
646 | +Reindex conditionally | ||
647 | + | ||
648 | +```ruby | ||
649 | +class Product < ActiveRecord::Base | ||
650 | + searchkick callbacks: false | ||
651 | + | ||
652 | + # add the callbacks manually | ||
653 | + after_save :reindex, if: proc{|model| model.name_changed? } # use your own condition | ||
654 | + after_destroy :reindex | ||
655 | +end | ||
656 | +``` | ||
657 | + | ||
646 | Reindex all models (Rails only) | 658 | Reindex all models (Rails only) |
647 | 659 | ||
648 | ```sh | 660 | ```sh |