Closed barodeur closed 3 weeks ago
This PR has been automatically marked as stale due to inactivity. The resources of our volunteers are limited. If this is something you are committed to continue working on, please address any concerns raised by review and/or ping us again. Thank you for all your contributions.
Thank you really much for PaperTrail.
I ran into a bug while using PaperTrail in a specific way:
t.string :whodunnit
I havet.references :whodunnit, foreign_key: {to_table: :users}
I really loved that this worked out of the box. But I eventually ran into a weird behavior:
PaperTrail.request.whodunnit
is an instance of aUser
PaperTrail.request(whodunnit:)
with a blockPaperTrail.request.whodunnit
is a dup (new record) of the initial user instance.This is particularly bad when creating another version right after because that new
User
dup will now be saved and duplicated.I did my best to add a test to highlight the problem with a new test. I understand that using an AR model as whodunnit value is not necessarily supported, but the proposed changed should not break the API.
Thank you
Check the following boxes:
master
(if not - rebase it).Added an entry to the Changelog if the new code introduces user-observable changes.