From e6ae05ea992cc6231d0d1bede35e16e7c9339228 Mon Sep 17 00:00:00 2001 From: Ben Atkins Date: Mon, 13 May 2013 10:17:07 -0400 Subject: [PATCH] Simplifying the nil attribute assignment fix, and making it so that it only happens when the item to be reified is the current version of the model --- lib/paper_trail/version.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/paper_trail/version.rb b/lib/paper_trail/version.rb index e58b29f8..df49599b 100644 --- a/lib/paper_trail/version.rb +++ b/lib/paper_trail/version.rb @@ -72,6 +72,8 @@ class Version < ActiveRecord::Base if item model = item + # Look for attributes that exist in the model and not in this version. These attributes should be set to nil. + (model.attribute_names - attrs.keys).each { |k| attrs[k] = nil } else inheritance_column_name = item_type.constantize.inheritance_column class_name = attrs[inheritance_column_name].blank? ? item_type : attrs[inheritance_column_name] @@ -81,12 +83,6 @@ class Version < ActiveRecord::Base model.class.unserialize_attributes_for_paper_trail attrs - # Look for attributes that exist in the model and not in this version. - # These attributes should be set to nil. - (model.attribute_names - attrs.keys).each do |k| - attrs[k] = nil - end - # Set all the attributes in this version on the model attrs.each do |k, v| if model.respond_to?("#{k}=")