diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 10:13:43 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-11-23 14:29:03 -0800 |
commit | ca7b0a0d1a424aec0973fe22c299b8f04e309784 (patch) | |
tree | 2d29ee8e070fe47f3160b1963ac45d6d97c18fa8 /activerecord/lib/active_record | |
parent | 0250c3eca40f5f2b3da698b11ff4f01f58db5a69 (diff) | |
download | rails-ca7b0a0d1a424aec0973fe22c299b8f04e309784.tar.gz rails-ca7b0a0d1a424aec0973fe22c299b8f04e309784.tar.bz2 rails-ca7b0a0d1a424aec0973fe22c299b8f04e309784.zip |
dup is working better
Diffstat (limited to 'activerecord/lib/active_record')
-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 9e15784f61..0d3df938e6 100644 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1420,7 +1420,7 @@ MSG @attributes = coder['attributes'] @attributes_cache, @previously_changed, @changed_attributes = {}, {}, {} @readonly = @destroyed = @marked_for_destruction = false - @persisted = true + @persisted = false _run_find_callbacks _run_initialize_callbacks end @@ -1615,11 +1615,15 @@ MSG @attributes.frozen? end + def initialize_dup(other) + super + init_with 'attributes' => other.attributes + self + end + # Returns duplicated record with unfreezed attributes. def dup - obj = super - obj.instance_variable_set('@attributes', @attributes.dup) - obj + super end # Returns +true+ if the record is read only. Records loaded through joins with piggy-back |