From 4cee51e1ccb592926e3d6e444d092ae7000531b0 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 13 Jan 2005 13:56:00 +0000 Subject: Refactored ActiveRecord::Base#clone to use Base#attributes #463 [atyp] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@401 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/base.rb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'activerecord') diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 1770026bb4..8b022ef6d4 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -808,17 +808,7 @@ module ActiveRecord #:nodoc: # Returns a clone of the record that hasn't been assigned an id yet and is treated as a new record. def clone - attr = Hash.new - - self.attribute_names.each do |name| - begin - attr[name] = read_attribute(name).clone - rescue TypeError - attr[name] = read_attribute(name) - end - end - - cloned_record = self.class.new(attr) + cloned_record = self.class.new(self.attributes) cloned_record.instance_variable_set "@new_record", true cloned_record.id = nil cloned_record -- cgit v1.2.3