aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-01-13 13:56:00 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-01-13 13:56:00 +0000
commit4cee51e1ccb592926e3d6e444d092ae7000531b0 (patch)
tree7f8f3cd1b60473bf34b992b6c16a55f01a7ff33d /activerecord/lib
parent96e54780b34ea6e8d8f972ff1f0b305aee44430c (diff)
downloadrails-4cee51e1ccb592926e3d6e444d092ae7000531b0.tar.gz
rails-4cee51e1ccb592926e3d6e444d092ae7000531b0.tar.bz2
rails-4cee51e1ccb592926e3d6e444d092ae7000531b0.zip
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
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/base.rb12
1 files changed, 1 insertions, 11 deletions
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