collectiveidea / audited

Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models.
MIT License
3.38k stars 659 forks source link

AuditedActions #468

Open clader opened 5 years ago

clader commented 5 years ago

Hi, I'm using Audited with the Paranoia gem (which soft deletes active record objects it's enabled on, but it otherwise is transparent to other references to those objects, so things look "really" deleted).

So If I want to lookup a deleted user object, instead of saying: u = User.find(2) I need to instead use: u = User.with_deleted.find(2) .. In order to retrieve the deleted record.

So, in relation to using the associations on an Audited::Audit object (like ".user" or ".auditable" etc), is there an easy way to "override" those association calls to active record objects to somehow include the ".with_deleted" option?

Obviously I'm wanting to still be able to display and link to activerecord objects from the audit object, even if the activerecord has been "soft" deleted.

Any ideas?

tbrisker commented 5 years ago

you can use the .auditable_id and .auditable_type or similar fields to get the proper id and class. otherwise it may be difficult to change since these relations are defined without the relevant scope on the audit. you could try redefining the e.g. has_one :auditable... relation to include the scope but i am not sure if that will work.