Browse files

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
  • Loading branch information...
1 parent 96e5478 commit 4cee51e1ccb592926e3d6e444d092ae7000531b0 @dhh dhh committed Jan 13, 2005
Showing with 1 addition and 11 deletions.
  1. +1 −11 activerecord/lib/active_record/base.rb
View
12 activerecord/lib/active_record/base.rb
@@ -808,17 +808,7 @@ def destroy
# 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

0 comments on commit 4cee51e

Please sign in to comment.