aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-07 13:43:44 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-07 13:43:44 +0000
commit431e21cb4510900619d83302d87788f5100e05ac (patch)
tree1b119a5a69d0ef0a17186d1faeb04092e006e274 /activerecord/lib/active_record/base.rb
parentdaee6fd92ac16878f6806c3382a9e74592aa9656 (diff)
downloadrails-431e21cb4510900619d83302d87788f5100e05ac.tar.gz
rails-431e21cb4510900619d83302d87788f5100e05ac.tar.bz2
rails-431e21cb4510900619d83302d87788f5100e05ac.zip
Fixed Base#clone for use with PostgreSQL #565 [hanson@surgery.wisc.edu]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@519 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-xactiverecord/lib/active_record/base.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 293fe0c833..3342fc7092 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -832,9 +832,9 @@ 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
- cloned_record = self.class.new(self.attributes)
- cloned_record.instance_variable_set "@new_record", true
- cloned_record.id = nil
+ attrs = self.attributes
+ attrs.delete(self.class.primary_key)
+ cloned_record = self.class.new(attrs)
cloned_record
end
@@ -1253,4 +1253,4 @@ module ActiveRecord #:nodoc:
string[0..3] == "--- "
end
end
-end \ No newline at end of file
+end