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
上级 96e54780
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册