diff --git a/app/models/application_model.rb b/app/models/application_model.rb index 80d08e0b8..41f1b8358 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -488,7 +488,10 @@ update search index, if configured - will be executed automatically def search_index_update return if !self.class.search_index_support_config - search_index_update_backend + + # start background job to transfer data to search index + return if !SearchIndexBackend.enabled? + Delayed::Job.enqueue( ApplicationModel::Job.new( self.class.to_s, self.id ) ) end =begin @@ -783,4 +786,11 @@ destory object dependencies, will be executed automatically def destroy_dependencies end + # perform background job + class ApplicationModel::Job < Struct.new( :object, :o_id ) + def perform + Object.const_get(object).find(o_id).search_index_update_backend + end + end + end