audited icon indicating copy to clipboard operation
audited copied to clipboard

Auditable type in single table inheritance.

Open CuriousAnkush opened this issue 9 years ago • 10 comments

I am using single table inheritance in rails, and I am auditing the parent class. Whenever, I create/update the child class/model, auditable type for that audit stores the name of the parent class instead of the name of the child class .

Is this feature of audited is intended, or is it just a side effect of SIT. What are the ways in which I could know the more specific auditable type in Single table inheritance?

CuriousAnkush avatar Jul 17 '15 06:07 CuriousAnkush

you can first fetch the record and then retrieve its name as every record of SIT will have unique id.

ChildObject.last.audits.last.auditable.class.name

jaswinder97 avatar Mar 28 '16 02:03 jaswinder97

@jaswinder97 - I agree with your explanation, but wouldn't this be part of the gem itself? I think @CuriousAnkush (and myself) are asking for the implementation within the gem. If you have a working fork, please post here.

vraravam avatar Sep 25 '16 17:09 vraravam

I have a forked version.Will post it today.

On 25 September 2016 at 22:42, Vijay Raghavan Aravamudhan < [email protected]> wrote:

@jaswinder97 https://github.com/jaswinder97 - I agree with your explanation, but wouldn't this be part of the gem itself? I think @CuriousAnkush https://github.com/CuriousAnkush (and myself) are asking for the implementation within the gem. If you have a working fork, please post here.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/collectiveidea/audited/issues/227#issuecomment-249433550, or mute the thread https://github.com/notifications/unsubscribe-auth/ARHmIZPg7UvHyh5O0fsisZTMXLJZuA85ks5qtqtmgaJpZM4FaeCz .

Thanks & Regards, Jaswinder Singh Software Engineer

jaswinder97 avatar Sep 26 '16 03:09 jaswinder97

@jaswinder97 - ping - could you please post the fork version soon?

vraravam avatar Sep 29 '16 18:09 vraravam

@jaswinder97 - can you please post the forked version? I need to get this solved asap - and would really appreciate your help!

vraravam avatar Oct 10 '16 15:10 vraravam

@vijay -Currently I am travelling .Will let you know after reaching my home.

On 10 October 2016 at 21:26, Vijay Raghavan Aravamudhan < [email protected]> wrote:

@jaswinder97 https://github.com/jaswinder97 - can you please post the forked version? I need to get this solved asap - and would really appreciate your help!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/collectiveidea/audited/issues/227#issuecomment-252663595, or mute the thread https://github.com/notifications/unsubscribe-auth/ARHmIeVxRItfMTWOJxIBEazyn5UYKnF6ks5qymAkgaJpZM4FaeCz .

Thanks & Regards, Jaswinder Singh Software Engineer

jaswinder97 avatar Oct 10 '16 16:10 jaswinder97

I believe it's the standard Rails behaviour to only store the parent class name in the type field when using STI with polymorphic associations (like audit's associated), per ActiveRecord::Associations: Polymorphic Associations.

Storing the subclass name in the type field can lead to problems using these associations in some versions of Rails, as it always expects the base class there.

domcleal avatar Apr 07 '17 07:04 domcleal

@jaswinder97 - While it's true that we can join/query the type on the base STI model when we create or update a model, we can't do so after we delete a model. It might be nice to provide a mechanism to remove inheritance_column from the default_ignored_attributes, so we can reconstruct what the type was on a deleted record.

ramfjord avatar Jun 27 '17 22:06 ramfjord

So there's no hope to get a solution like #368 merged?

wynksaiddestroy avatar Sep 04 '17 13:09 wynksaiddestroy

Any update on this? In my opinion, identifying the source model should not be dependent on still having access to the record (e.g. after deleting a record)

drale2k avatar Feb 23 '20 15:02 drale2k