From 16dc139caa9286638785469304a69ab77e4fe9b5 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 1 Jul 2009 12:16:35 -0700 Subject: Added AR:B#dup method for duplicationg object without frozen attributes [#2859 state:resolved] Signed-off-by: Yehuda Katz + Carl Lerche --- activerecord/lib/active_record/base.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/lib/active_record') 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? -- cgit v1.2.3