I've set papertrail to only record changes containing a whodunnit value/when an admin makes a change by using the below condition in my model:
has_paper_trail if: proc { |model| PaperTrail.request.whodunnit.present? }
However I've noticed there are still a decent amount of records being stored with empty whodunnit values. From having a look at the records, these seem to be mostly 'update' actions all having empty object changes for some reason. I am unsure as to why the value is empty, or how it would get saved at all considering the above condition.
I am getting whodunnit values from warden in my application controller using:
def user_for_paper_trail
request.env['warden']&.user(:admin)&.id
end
Has anyone come across similar behaviour before?