Commit 8cd48234bffc13c1d1dd792b033f9eb738e95474

Authored by Andrew Kane
1 parent f94568d7

Use class_name for inheritance

lib/searchkick/bulk_indexer.rb
@@ -61,7 +61,7 @@ module Searchkick @@ -61,7 +61,7 @@ module Searchkick
61 if records.any? 61 if records.any?
62 if async 62 if async
63 Searchkick::BulkReindexJob.perform_later( 63 Searchkick::BulkReindexJob.perform_later(
64 - class_name: records.first.model_name.name, 64 + class_name: records.first.class.searchkick_options[:class_name],
65 record_ids: records.map(&:id), 65 record_ids: records.map(&:id),
66 index_name: index.name, 66 index_name: index.name,
67 method_name: method_name ? method_name.to_s : nil 67 method_name: method_name ? method_name.to_s : nil
@@ -140,7 +140,7 @@ module Searchkick @@ -140,7 +140,7 @@ module Searchkick
140 def bulk_reindex_job(scope, batch_id, options) 140 def bulk_reindex_job(scope, batch_id, options)
141 Searchkick.with_redis { |r| r.sadd(batches_key, batch_id) } 141 Searchkick.with_redis { |r| r.sadd(batches_key, batch_id) }
142 Searchkick::BulkReindexJob.perform_later({ 142 Searchkick::BulkReindexJob.perform_later({
143 - class_name: scope.model_name.name, 143 + class_name: scope.searchkick_options[:class_name],
144 index_name: index.name, 144 index_name: index.name,
145 batch_id: batch_id 145 batch_id: batch_id
146 }.merge(options)) 146 }.merge(options))
lib/searchkick/model.rb
@@ -15,6 +15,7 @@ module Searchkick @@ -15,6 +15,7 @@ module Searchkick
15 Searchkick.models << self 15 Searchkick.models << self
16 16
17 options[:_type] ||= -> { searchkick_index.klass_document_type(self, true) } 17 options[:_type] ||= -> { searchkick_index.klass_document_type(self, true) }
  18 + options[:class_name] = model_name.name
18 19
19 callbacks = options.key?(:callbacks) ? options[:callbacks] : :inline 20 callbacks = options.key?(:callbacks) ? options[:callbacks] : :inline
20 unless [:inline, true, false, :async, :queue].include?(callbacks) 21 unless [:inline, true, false, :async, :queue].include?(callbacks)