diff --git a/.gitignore b/.gitignore index 0b09a3e5..63bad86b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,5 @@ pkg/* .rbenv-version Gemfile.lock vendor/* +.idea +.rvmrc diff --git a/lib/paper_trail/has_paper_trail.rb b/lib/paper_trail/has_paper_trail.rb index 880fc1f3..a98b36a1 100644 --- a/lib/paper_trail/has_paper_trail.rb +++ b/lib/paper_trail/has_paper_trail.rb @@ -97,7 +97,7 @@ module PaperTrail # Returns who put the object into its current state. def originator - version_class.with_item_keys(self.class.name, id).last.try :whodunnit + version_class.with_item_keys(self.class.base_class.name, id).last.try :whodunnit end # Returns the object (not a Version) as it was at the given timestamp. diff --git a/test/unit/model_test.rb b/test/unit/model_test.rb index b5683b1d..daa1e9f6 100644 --- a/test/unit/model_test.rb +++ b/test/unit/model_test.rb @@ -517,6 +517,12 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase assert_nil Version.last.next end + should 'should return the correct originator' do + PaperTrail.whodunnit = 'Ben' + @foo.update_attribute(:name, 'Geoffrey') + assert_equal PaperTrail.whodunnit, @foo.originator + end + context 'when destroyed' do setup { @foo.destroy }