collectiveidea / audited

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

Auditable type in single table inheritance. #227

Open CuriousAnkush opened 9 years ago

CuriousAnkush commented 9 years ago

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?

jaswinder97 commented 8 years ago

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

vraravam commented 8 years ago

@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.

jaswinder97 commented 8 years ago

I have a forked version.Will post it today.

On 25 September 2016 at 22:42, Vijay Raghavan Aravamudhan < notifications@github.com> 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

vraravam commented 8 years ago

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

vraravam commented 8 years ago

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

jaswinder97 commented 8 years ago

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

On 10 October 2016 at 21:26, Vijay Raghavan Aravamudhan < notifications@github.com> 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

domcleal commented 7 years ago

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.

ramfjord commented 7 years ago

@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.

wynksaiddestroy commented 7 years ago

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

drale2k commented 4 years ago

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)