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

Support auditing needs by switching to has_many, through #583

Closed
wants to merge 6 commits into from
Closed

Support auditing needs by switching to has_many, through #583

wants to merge 6 commits into from

Conversation

brettwgreen
Copy link

@brettwgreen brettwgreen commented Aug 31, 2022

Switch from HABTM to has_many and has_many through:

This will allow users to add columns like id and created_at to the intermediate table and use paper_trail to track changes to this table, as well as gems like paranoia to soft-delete those records. All of this is super-important from a security auditing perspective.

Pulled code from a PR made about 9 months ago that failed tests and was abandoned. Made further changes based on my own needs to adequately support timestamp columns, soft-delete (paranoia) and paper_trail.

I am deliberately removing the records in the join table using destroy_all to trigger proper eventing with timestamps and paper_trail, and then still honoring the options removal of role records no longer in use.

@brettwgreen brettwgreen changed the title use has_many, through Support auditing needs by switching to use has_many, through Aug 31, 2022
@brettwgreen brettwgreen changed the title Support auditing needs by switching to use has_many, through Support auditing needs by switching to has_many, through Aug 31, 2022
@brettwgreen
Copy link
Author

Still working through issues with callbacks... will reopen later

@brettwgreen brettwgreen closed this Sep 1, 2022
@khiav223577
Copy link

Looking forward to this feature!

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