audited
audited copied to clipboard
Auditable type in single table inheritance.
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?
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 - 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.
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 - ping - could you please post the fork version soon?
@jaswinder97 - can you please post the forked version? I need to get this solved asap - and would really appreciate your help!
@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
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.
@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.
So there's no hope to get a solution like #368 merged?
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)