We are trying to overide the reindex method of Searchkick in order to avoid reindexing in case we are on local env.
So we created a initializers/record_indexer.rb :
class Searchkick::RecordIndexer
def reindex(options= {})
unless Rails.env == 'local'
super(options)
end
end
end
When I try to update an associated model that cause a reindexation of my 'indexed record' it throws a NoMethodError (super: no superclass method `reindex' for #<Searchkick::RecordIndexer)
I notice that searchkick has at least 3 reindex methods in:
Did someone already have this kind of problematic on the #reindex method of Gem Searckick (v4.4.2)?
In your code you are completely replacing a method with your implementation.
If you override a method, and want to call the original, you have two options:
Store the original method with an alias
class Searchkick::RecordIndexer
alias_method :orig_reindex, :reindex
def reindex(options={})
unless Rails.env == 'local'
orig_reindex(options)
end
end
end
Prepend a module
module YourPatch
def reindex(options={})
unless Rails.env == 'local'
super # no need to specify args if it's just pass-through
end
end
end
Searchkick::RecordIndexer.prepend(YourPatch)