airblade/paper_trail — pull request #168 by l4rk (2012-08-13 23:32:35+00:00)
Title: Support conditional paper trail on destroy

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!