aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2013-04-19 06:19:06 -0700
committerJon Leighton <j@jonathanleighton.com>2013-04-19 06:19:06 -0700
commit77fec1344bfbf7c01f595afbf752633c0eaeed10 (patch)
tree1d8ee07da37b0972e46b94c389f1741893ccb609 /activerecord/lib
parent30f9237b8eb4e445f5e1ce898581dff6675c28ee (diff)
parentd5867a01a82d14216541c8bfc38e466b02580376 (diff)
downloadrails-77fec1344bfbf7c01f595afbf752633c0eaeed10.tar.gz
rails-77fec1344bfbf7c01f595afbf752633c0eaeed10.tar.bz2
rails-77fec1344bfbf7c01f595afbf752633c0eaeed10.zip
Merge pull request #10200 from calebthompson/ct-fix-freeze-freezing-cloned-models
Fix freeze applying to cloned objects
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/core.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 733d4e1c67..9e45e6e474 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -307,9 +307,11 @@ module ActiveRecord
id.hash
end
- # Freeze the attributes hash such that associations are still accessible, even on destroyed records.
+ # Clone and freeze the attributes hash such that associations are still
+ # accessible, even on destroyed records, but cloned models will not be
+ # frozen.
def freeze
- @attributes.freeze
+ @attributes = @attributes.clone.freeze
self
end