From 3919fcd61ef999aab9397332ce3017870b184766 Mon Sep 17 00:00:00 2001 From: Guillermo Iguaran Date: Fri, 14 Sep 2012 15:29:55 -0500 Subject: [PATCH] Set primary key with id= only if primary key exists --- activerecord/lib/active_record/attribute_methods/primary_key.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb index 383448c94a..aa6704d5c9 100644 --- a/activerecord/lib/active_record/attribute_methods/primary_key.rb +++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb @@ -18,7 +18,7 @@ module ActiveRecord # Sets the primary key value def id=(value) - write_attribute(self.class.primary_key, value) + write_attribute(self.class.primary_key, value) if self.class.primary_key end # Queries the primary key value