diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 11:57:33 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 14:29:05 -0800 |
commit | 064c28d6c290cb9b6222b2348e38e713b82a89d6 (patch) | |
tree | 70d895e0f813cb38f4b80fa913c102f655d5b183 /activerecord/lib/active_record/base.rb | |
parent | 93d78b831831a1c8e324d4c5404b99e81fe77725 (diff) | |
download | rails-064c28d6c290cb9b6222b2348e38e713b82a89d6.tar.gz rails-064c28d6c290cb9b6222b2348e38e713b82a89d6.tar.bz2 rails-064c28d6c290cb9b6222b2348e38e713b82a89d6.zip |
fixing dup regressions
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r-- | activerecord/lib/active_record/base.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index f9de4b7918..7cc4f957fe 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1592,8 +1592,8 @@ MSG end # Duped objects have no id assigned and are treated as new records. Note - # that this is a "shallow" clone as it copies the object's attributes - # only, not its associations. The extent of a "deep" dup is application + # that this is a "shallow" copy as it copies the object's attributes + # only, not its associations. The extent of a "deep" copy is application # specific and is therefore left to the application to implement according # to its need. def initialize_dup(other) @@ -1602,8 +1602,12 @@ MSG cloned_attributes = other.clone_attributes(:read_attribute_before_type_cast) cloned_attributes.delete(self.class.primary_key) - @attributes = cloned_attributes - @changed_attributes = other.changed_attributes.dup + @attributes = cloned_attributes + + @changed_attributes = {} + attributes_from_column_definition.each do |attr, orig_value| + @changed_attributes[attr] = orig_value if field_changed?(attr, orig_value, @attributes[attr]) + end clear_aggregation_cache clear_association_cache |