Skip to content

Commit

Permalink
Refactored ActiveRecord::Base#clone to use Base#attributes rails#463
Browse files Browse the repository at this point in the history
…[atyp]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@401 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Jan 13, 2005
1 parent 96e5478 commit 4cee51e
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -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
Expand Down

0 comments on commit 4cee51e

Please sign in to comment.