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

Originator does not respect inheritance #166

Closed
pmatsinopoulos opened this issue Jul 17, 2012 · 0 comments
Closed

Originator does not respect inheritance #166

pmatsinopoulos opened this issue Jul 17, 2012 · 0 comments

Comments

@pmatsinopoulos
Copy link

Hi @airblade ,

I have a problem with originator method. It does not respect inheritance the way it should. Let me explain.

If we have the following model:

class Person < ActiveRecord::Base
   has_paper_trail 
end

and

class Employee < Person
end

When you create an Employee the column item_type on Versions table takes the value Person, which is correct according to Rails polymorphic associations (it has to contain the base class name). For the same good practice, the reify method respects the inheritance and polymorphic mechanism correct: It expects the item_type to contain the base class.

On the other hand, the originator method, which has the following code:

def originator
  version_class.with_item_keys(self.class.name, id).last.try :whodunnit
end

when called on Employee instance will try to fetch the entries of Versions table which have value Employee, and none will be found. This is due to the self.class.name part of the originator method implementation. I believe it should have been self.class.base_class.name instead, but you are the person to decide whether my suggestion is correct or not.

@pmatsinopoulos

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

No branches or pull requests

2 participants