mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
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
This commit is contained in:
parent
05468001af
commit
e6ae05ea99
1 changed files with 2 additions and 6 deletions
|
@ -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}=")
|
||||
|
|
Loading…
Reference in a new issue