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

Added in_after_callback argument to save_with_version #1371

Merged

Conversation

denisahearn
Copy link
Contributor

My application calls PaperTrail::RecordTrail#save_with_version in an after callback. The version record that this method creates does not record the current changes on the object being tracked. I found the cause in the PaperTrail::Events::Base#load_changes_in_latest_version method, which only uses @record.saved_changes when @in_after_callback is true. Unfortunately I don't currently see a way to make @in_after_callback == true when using save_with_version.

This pull request adds an in_after_callback argument to the PaperTrail::RecordTrail#save_with_version method, to allow the caller to indicate if this method is being called during an after callback. The argument defaults to false when not provided.

Check the following boxes:

  • Wrote good commit messages.
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Added an entry to the Changelog if the new
    code introduces user-observable changes.
  • The PR relates to only one subject with a clear title
    and description in grammatically correct, complete sentences.

@jaredbeck
Copy link
Member

Hi Denis, thanks for the contribution. I'm not sure how many people will use this new feature, but there aren't really any good alternatives that I can think of. It's a good PR too :) You've ticked all the boxes.

@jaredbeck jaredbeck merged commit 66d0043 into paper-trail-gem:master Mar 9, 2022
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