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

Single Table Inherited audits #270

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jaswinder97
Copy link

Single Table Inheritance will always store parent class name as auditable_type name instead of child class name but we can retrieve the actual child class name by first retrieving the auditable record and then identify its class name.

Copy link
Collaborator

@domcleal domcleal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay! Just some minor comments.

Synario:
```ruby
class Patient < ActiveRecord::Base
has_many :diseases
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, indentation should be two spaces (here and below).

@@ -265,6 +265,35 @@ class User < ActiveRecord::Base
attr_protected :logins, :audit_ids
end
```
### Single Table Inherited(STI) table audits

If you're making audits for a STI record ,then you'll have to change your steps to identify the record's model.You wouldn't be able to retrieve `auditable_type` for the child table record associated audits as it always give parent table class name.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space before "You wouldn't"


If you're making audits for a STI record ,then you'll have to change your steps to identify the record's model.You wouldn't be able to retrieve `auditable_type` for the child table record associated audits as it always give parent table class name.

Synario:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scenario

```ruby
Patient.last.associated_audits.last.auditable.class.name
```
Actually, in Single table inheritance (STI) each record will have a unique id so you can identify the record using the record id from the parent class as
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here would be a good place to note that this only works if the audited record still exists (auditable may be nil).

@tbrisker
Copy link
Collaborator

This PR has been open for over a year now with no activity. @jaswinder97 , do you think it's still needed and would you be interested in returning to this or should we close it?

@tbrisker tbrisker added the Stale label Feb 21, 2018
@jaswinder97
Copy link
Author

jaswinder97 commented Feb 21, 2018 via email

@tbrisker
Copy link
Collaborator

tbrisker commented Apr 1, 2018

Ping @jaswinder97 ? do you think you'll get to this?

@jaswinder97
Copy link
Author

jaswinder97 commented Apr 1, 2018 via email

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

Successfully merging this pull request may close these issues.

None yet

3 participants