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

Support conditional paper trail on destroy #168

Merged
merged 1 commit into from Nov 6, 2012

Conversation

l4rk
Copy link

@l4rk l4rk commented Aug 13, 2012

Howdy!

Background: We have a paper-trailed Contact model which has_many :email_addresses. The EmailAddress model also has a paper trail. We have a custom way of undo-ing deletes of parents, and all their children.

Problem: If someone blanks out an email in the web UI, then we destroy that email row. But, we don't want a EmailAddress version to be created in that case.

Other problem: However, we do want to save a version of both the EmailAddress and the Contact, when a contact is deleted.

Solution: Pass along the :if conditional to the destroy code. We have a conditional expression that knows the difference between the parent Contact delete, versus the one-off deletion of an EmailAddress due to blanking it out in the UI.

Thanks!

@travisbot
Copy link

This pull request fails (merged a517bc3 into e870e0d).

@l4rk
Copy link
Author

l4rk commented Aug 13, 2012

BTW, the tests pass for us on an older version of Rails. paper_trail will need to be tweaked to keep up with the latest Rails.

@batter
Copy link
Collaborator

batter commented Nov 6, 2012

Thanks, this does indeed appear to be a bug. If the :if conditional is not met, then a version should not be saved for a destroy action either.

batter pushed a commit that referenced this pull request Nov 6, 2012
@batter batter merged commit a517bc3 into paper-trail-gem:master Nov 6, 2012
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.

None yet

3 participants