aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-10-08 06:21:38 +0000
committerMichael Koziarski <michael@koziarski.com>2007-10-08 06:21:38 +0000
commit3122d321fd5d05d549274487e5a52f3a73bc6f43 (patch)
tree11d92375dd5ac760b3ef75148836794f30ab2592 /activerecord/lib/active_record
parent4eaa8ba5bec9001e97349e7dfd565c7215085834 (diff)
downloadrails-3122d321fd5d05d549274487e5a52f3a73bc6f43.tar.gz
rails-3122d321fd5d05d549274487e5a52f3a73bc6f43.tar.bz2
rails-3122d321fd5d05d549274487e5a52f3a73bc6f43.zip
Make sure AR::Base#clone handles attr changes made in after_initialize hooks. Closes #7191 [weyus]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7802 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-xactiverecord/lib/active_record/base.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 8b562e2ffb..8d98796af1 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1751,9 +1751,9 @@ module ActiveRecord #:nodoc:
def clone
attrs = self.attributes_before_type_cast
attrs.delete(self.class.primary_key)
- self.class.new do |record|
- record.send :instance_variable_set, '@attributes', attrs
- end
+ record = self.class.new
+ record.send :instance_variable_set, '@attributes', attrs
+ record
end
# Updates a single attribute and saves the record. This is especially useful for boolean flags on existing records.