aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-01 12:16:35 -0700
committerYehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>2009-07-01 12:16:35 -0700
commit16dc139caa9286638785469304a69ab77e4fe9b5 (patch)
tree82e7e7f79428e0adf0e120e49361628bcd2474a8 /activerecord/lib/active_record
parent882dd4e6054470ee56c46ab1432861952c81b633 (diff)
downloadrails-16dc139caa9286638785469304a69ab77e4fe9b5.tar.gz
rails-16dc139caa9286638785469304a69ab77e4fe9b5.tar.bz2
rails-16dc139caa9286638785469304a69ab77e4fe9b5.zip
Added AR:B#dup method for duplicationg object without frozen attributes [#2859 state:resolved]
Signed-off-by: Yehuda Katz + Carl Lerche <ykatz+clerche@engineyard.com>
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/base.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index ff5a836b52..deab56e219 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -2870,6 +2870,13 @@ module ActiveRecord #:nodoc:
@attributes.frozen?
end
+ # Returns duplicated record with unfreezed attributes.
+ def dup
+ obj = super
+ obj.instance_variable_set('@attributes', instance_variable_get('@attributes').dup)
+ obj
+ end
+
# Returns +true+ if the record is read only. Records loaded through joins with piggy-back
# attributes will be marked as read only since they cannot be saved.
def readonly?