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

PaperTrail + Inheritance #2865

Merged
merged 1 commit into from
May 6, 2019
Merged

PaperTrail + Inheritance #2865

merged 1 commit into from
May 6, 2019

Conversation

lazebny
Copy link
Contributor

@lazebny lazebny commented Apr 1, 2017

This PR resolves issues #1524, #2332, #2691
It is based on https://github.com/sferik/rails_admin/pull/1567/files.

PaperTrail stores a base_class for each subclass, so we can't fetch versions with searching by subclass. STI model allows us to fetch records with query condition which includes STI type, so model.model.all should return a valid AR relation for current STI type and we can fetch a versions by this relation.

When we have a deal with object versions think we can't do better than to use native PaperTrail method versions, so object.versions should work well.

These changes were checked on our production db.

Here is illustration how PaperTrail works:

class PaperTrailTest; end
class PaperTrailTestSubclass < ::PaperTrailTest; end
class PaperTrailTest::SubclassInNamespace < PaperTrailTest; end
versions = PaperTrail::Version.where(item_type: 'PaperTrailTest')
PaperTrailTest.create
versions.count # 1
PaperTrailTestSubclass.create
versions.count # 2
PaperTrailTest::SubclassInNamespace.create
versions.count # 3

@vshmyhlo
Copy link

vshmyhlo commented Apr 5, 2017

👍 i have same issue, would be nice to have these changes in master

@mshibuya mshibuya added this to the 2.0.0 milestone May 2, 2019
@mshibuya mshibuya merged commit f0de1cf into railsadminteam:master May 6, 2019
mshibuya added a commit that referenced this pull request May 6, 2019
@mshibuya
Copy link
Member

mshibuya commented May 6, 2019

Excellent, thanks!

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

Successfully merging this pull request may close these issues.

3 participants