0

I am using elasticsearch-rails gem For my site i need to create custom callbacks. https://github.com/elastic/elasticsearch-rails/tree/master/elasticsearch-model#custom-callbacks But i really confused by one thing. What means if self.published? on this code? i try to use this for my models

after_commit on: [:update] do
  place.__elasticsearch__.update_document if self.published?
end

but for model in console i see self.published? => false but i don`t know what this means

Stary
  • 178
  • 10

1 Answers1

0

From the document of elasticsearch-rails.

For ActiveRecord-based models, use the after_commit callback to protect your data against inconsistencies caused by transaction rollbacks:

I think it was used to make sure everything is updated successfully into database before we sync to elasticsearch server

Invoker
  • 106
  • 2
  • 6