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

Auditable type in single table inheritance. #227

Open
CuriousAnkush opened this issue Jul 17, 2015 · 10 comments
Open

Auditable type in single table inheritance. #227

CuriousAnkush opened this issue Jul 17, 2015 · 10 comments
Labels

Comments

@CuriousAnkush
Copy link

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
Copy link

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
Copy link

@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
Copy link

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
#227 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARHmIZPg7UvHyh5O0fsisZTMXLJZuA85ks5qtqtmgaJpZM4FaeCz
.

Thanks & Regards,
Jaswinder Singh
Software Engineer

@vraravam
Copy link

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

@vraravam
Copy link

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

@jaswinder97
Copy link

@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
#227 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARHmIeVxRItfMTWOJxIBEazyn5UYKnF6ks5qymAkgaJpZM4FaeCz
.

Thanks & Regards,
Jaswinder Singh
Software Engineer

@domcleal
Copy link
Collaborator

domcleal commented Apr 7, 2017

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
Copy link

@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
Copy link

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

@drale2k
Copy link

drale2k commented Feb 23, 2020

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants