Commit c197a152564f5288473389517fae3c902243da0a

Authored by Andrew Kane
1 parent 7a4384b9

Prevented scope from affecting search_data [skip ci]

Showing 1 changed file with 6 additions and 2 deletions   Show diff stats
lib/searchkick/model.rb
... ... @@ -72,8 +72,12 @@ module Searchkick
72 72 alias_method :search_index, :searchkick_index unless method_defined?(:search_index)
73 73  
74 74 def searchkick_reindex(method_name = nil, **options)
75   - relation = Searchkick.relation?(self)
76   - searchkick_index.reindex(searchkick_klass, method_name, scoped: relation, **options)
  75 + scoped = Searchkick.relation?(self)
  76 + relation = scoped ? all : searchkick_klass
  77 + # prevent scope from affecting search_data
  78 + unscoped do
  79 + searchkick_index.reindex(relation, method_name, scoped: scoped, **options)
  80 + end
77 81 end
78 82 alias_method :reindex, :searchkick_reindex unless method_defined?(:reindex)
79 83  
... ...