Skip to content

Commit 9fec676

Browse files
committed
Improve README suggestion for async indexing with after_save_commit
* after_commit solves testing problems by ensuring create is committed * Use rails 6's after_save_commit to avoid reindexing on destroy
1 parent 03fa16b commit 9fec676

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

elasticsearch-model/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ with a tool like [_Resque_](https://github.com/resque/resque) or [_Sidekiq_](htt
506506
class Article
507507
include Elasticsearch::Model
508508

509-
after_save { Indexer.perform_async(:index, self.id) }
510-
after_destroy { Indexer.perform_async(:delete, self.id) }
509+
after_save_commit { Indexer.perform_async(:index, self.id) }
510+
after_destroy { Indexer.perform_async(:delete, self.id) }
511511
end
512512
```
513513

0 commit comments

Comments
 (0)