Commit 426229d033be68d365158ce0599c04836f8201ea
1 parent
616c0eaf
Exists in
master
and in
21 other branches
Updated reindex
Showing
2 changed files
with
9 additions
and
12 deletions
Show diff stats
lib/searchkick/model.rb
... | ... | @@ -8,10 +8,6 @@ module Searchkick |
8 | 8 | class_variable_set :@@searchkick_klass, self |
9 | 9 | cattr_reader :searchkick_options, :searchkick_env, :searchkick_klass |
10 | 10 | |
11 | - def self.searchkick_index | |
12 | - searchkick_klass.tire.index | |
13 | - end | |
14 | - | |
15 | 11 | extend Searchkick::Search |
16 | 12 | extend Searchkick::Reindex |
17 | 13 | include Searchkick::Similar |
... | ... | @@ -22,16 +18,17 @@ module Searchkick |
22 | 18 | |
23 | 19 | tire.index_name index_name |
24 | 20 | |
25 | - descendants.each do |subclass| | |
26 | - subclass.tire.index_name index_name | |
27 | - end | |
28 | - | |
29 | - def self.inherited(subclass) | |
30 | - subclass.tire.index_name index_name | |
21 | + def self.searchkick_index | |
22 | + searchkick_klass.tire.index | |
31 | 23 | end |
32 | 24 | |
33 | 25 | def reindex |
34 | - tire.update_index | |
26 | + index = self.class.searchkick_index | |
27 | + if destroyed? | |
28 | + index.remove self | |
29 | + else | |
30 | + index.store self | |
31 | + end | |
35 | 32 | end |
36 | 33 | |
37 | 34 | unless options[:callbacks] == false | ... | ... |
test/inheritance_test.rb