Skip to content

PaperTrail + Inheritance#2865

Merged
mshibuya merged 1 commit into
railsadminteam:masterfrom
lazebny:papertrail-with-inheritance
May 6, 2019
Merged

PaperTrail + Inheritance#2865
mshibuya merged 1 commit into
railsadminteam:masterfrom
lazebny:papertrail-with-inheritance

Conversation

@lazebny

@lazebny lazebny commented Apr 1, 2017

Copy link
Copy Markdown
Contributor

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

vshmyhlo commented Apr 5, 2017

Copy link
Copy Markdown

👍 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

mshibuya commented May 6, 2019

Copy link
Copy Markdown
Member

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