Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use destroy_all rather than delete_all when creating historical… #924

Merged
merged 4 commits into from
Nov 20, 2019

Conversation

alexdean
Copy link
Contributor

Our application adds an after_commit callback to FriendlyId::Slug. The usage of delete_all rather than destroy_all in FriendlyId::History::FinderMethods#create_slug means that this callback is not always invoked.

This PR changes this delete_all to a destroy_all, which will invoke callbacks for the deleted records. Performance impact should be minimal given that (at most) 1 record is loaded and then deleted.

Additionally: I noticed that no tests failed when i removed the delete_all call entirely. I think the test I've added will guard against that.

if users augment FriendlyId::Slug with callbacks, they should be invoked
alexdean and others added 2 commits November 20, 2019 14:31
remove unintentional whitespace.

Co-Authored-By: Philip Arndt <git@p.arndt.io>
@parndt
Copy link
Collaborator

parndt commented Nov 20, 2019

Thank you @alexdean ! 👍 🥇

@parndt parndt changed the title use destroy_all rather than delete_all when creating historical slugs use destroy_all rather than delete_all when creating historical… Nov 20, 2019
@parndt parndt merged commit 081b4e5 into norman:master Nov 20, 2019
@alexdean
Copy link
Contributor Author

happy to help!

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