aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
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