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

Try to create a version record when associated object is touched #1376

Merged
merged 1 commit into from
Mar 9, 2022

Conversation

y-yagi
Copy link
Contributor

@y-yagi y-yagi commented Mar 1, 2022

Before #1285, a version record was created when associated object is touched.
But because of Rails don't track implicit touch mutation1, now PaperTail don't create a version record was created when associated object is touched.

This patch try to keep creating a version record in that case by doing checking an event and changed value.

Fixes #1339.


Thank you for your contribution!

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.

Before paper-trail-gem#1285, a version record was created when associated object is touched.
But because of Rails don't track implicit touch mutation[1], now PaperTail
don't create a version record was created when associated object is touched.

This patch try to keep creating a version record in that case by doing checking an
event and changed value.

Fixes paper-trail-gem#1339.

[1]: rails/rails@dcb8259
@jaredbeck
Copy link
Member

LGTM. WDYT @westonganger @quainjn @tlynam ?

@westonganger
Copy link
Contributor

Sure looks good I guess, not sure I should be considered an expert here though.

@jaredbeck jaredbeck merged commit 29c4d37 into paper-trail-gem:master Mar 9, 2022
@jaredbeck
Copy link
Member

Thanks @y-yagi !

@y-yagi
Copy link
Contributor Author

y-yagi commented Mar 9, 2022

Thanks for your review!

@y-yagi y-yagi deleted the fix-1339 branch March 9, 2022 07:49
@KevinBongart
Copy link

Thank @y-yagi for the patch! I noticed the same issue, identified the root cause and found this PR before I attempted to fix it :D

@jaredbeck Any ETA for when this patch will make its way into a new release?

@steve21168
Copy link

I'm actually looking to do the opposite of this. I don't want a version record when the association is touched. In my case it's creating extraneous version records showing no object changes.

To fix this, I added has_paper_trail ignore: [:updated_at]. However this change doesn't take into account ignore or skip. So now when associated objects are touched there's no way to avoid these version records.

Any ideas to work around this?

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.

The versions doesn't create when associated object deleted since v12.1.0.
5 participants