Commit e0afe80f69310411b60ba869bbe6d1aafd3912d3
1 parent
ef30d536
Exists in
scope_attributes
Fixed scope_attributes - #1511
Showing
1 changed file
with
6 additions
and
3 deletions
Show diff stats
lib/searchkick/model.rb
@@ -57,11 +57,14 @@ module Searchkick | @@ -57,11 +57,14 @@ module Searchkick | ||
57 | alias_method :search_index, :searchkick_index unless method_defined?(:search_index) | 57 | alias_method :search_index, :searchkick_index unless method_defined?(:search_index) |
58 | 58 | ||
59 | def searchkick_reindex(method_name = nil, **options) | 59 | def searchkick_reindex(method_name = nil, **options) |
60 | - # TODO relation = Searchkick.relation?(self) | ||
61 | - relation = (respond_to?(:current_scope) && respond_to?(:default_scoped) && current_scope && current_scope.to_sql != default_scoped.to_sql) || | 60 | + # TODO scoped = Searchkick.relation?(self) |
61 | + scoped = (respond_to?(:current_scope) && respond_to?(:default_scoped) && current_scope && current_scope.to_sql != default_scoped.to_sql) || | ||
62 | (respond_to?(:queryable) && queryable != unscoped.with_default_scope) | 62 | (respond_to?(:queryable) && queryable != unscoped.with_default_scope) |
63 | 63 | ||
64 | - searchkick_index.reindex(searchkick_klass, method_name, scoped: relation, **options) | 64 | + relation = scoped ? all : searchkick_klass |
65 | + unscoped do | ||
66 | + searchkick_index.reindex(relation, method_name, scoped: scoped, **options) | ||
67 | + end | ||
65 | end | 68 | end |
66 | alias_method :reindex, :searchkick_reindex unless method_defined?(:reindex) | 69 | alias_method :reindex, :searchkick_reindex unless method_defined?(:reindex) |
67 | 70 |