Skip to content

Conversation

trappist
Copy link

I got a lot of test failures using the original suggestion. First because newly created records weren't yet committed when the (test) worker ran, so I switched to after_commit. But after_commit also fires on destroy, so it would fail trying to reindex destroyed records. Rails 6 introduces after_save_commit for this purpose. Prior to Rails 6 it would be after_commit ..., on: [:create, :update], but if you needed to change the next line to after_commit ..., on: :destroy the latter callback would clobber the former, and this prevents that.

* after_commit solves testing problems by ensuring create is committed
* Use rails 6's after_save_commit to avoid reindexing on destroy
@cla-checker-service
Copy link

❌ Author of the following commits did not sign a Contributor Agreement:
9fec676

Please, read and sign the above mentioned agreement if you want to contribute to this project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants