How to set both the user and username in audited gem
A while ago I was working on the audit log and wanted to store both the user and the name. That way the name remains and can be shown if the user is deleted. The audited gem stores either/or, not both, but it was simple enough to override it.
First, override the model:
And in the model:
This uses audited’s own mechanism for setting the username in case it’s not already set.