Commit 79a5e5568563d7bff0734df845f8370bf8d4db67

Authored by Rafael Martins
1 parent 9dedafae

Fixes for acts_as_solr_reloaded

* after_save_reindex works from non-indexed classes
vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/acts_methods.rb
... ... @@ -300,6 +300,7 @@ module ActsAsSolr #:nodoc:
300 300 end
301 301  
302 302 def after_save_reindex(associations, options = {})
  303 + extend ActsAsSolr::CommonMethods
303 304 Array(associations).each do |association|
304 305 after_save do |ar|
305 306 if options[:with] == :delayed_job
... ...
vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/common_methods.rb
... ... @@ -30,11 +30,14 @@ module ActsAsSolr #:nodoc:
30 30 end
31 31  
32 32 def solr_batch_add(objects)
33   - solr_add Array(objects).map{ |a| a.to_solr_doc }
  33 + solr_add objects.map{ |a| a.to_solr_doc }
  34 + solr_commit if defined?(configuration) and configuration[:auto_commit]
34 35 end
35 36  
36 37 def solr_batch_add_association(ar, association)
37   - solr_batch_add ar.send(association)
  38 + result = ar.send(association)
  39 + result = [result] unless result.is_a?(Array)
  40 + solr_batch_add result
38 41 end
39 42  
40 43 # Sends an add command to Solr
... ...