aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods
diff options
context:
space:
mode:
authorJulius de Bruijn <julius.bruijn@sponsorpay.com>2011-11-30 17:56:16 +0100
committerJon Leighton <j@jonathanleighton.com>2011-11-30 23:47:16 +0000
commit4e380828ffa8279740256164c6b83148cf0cbf13 (patch)
treed91bb7b1732dad4602d12668cd734d48cb93d8fc /activerecord/lib/active_record/attribute_methods
parent7a4949e7d5be37f64bf6a1f9dda6f427fbb5ac40 (diff)
downloadrails-4e380828ffa8279740256164c6b83148cf0cbf13.tar.gz
rails-4e380828ffa8279740256164c6b83148cf0cbf13.tar.bz2
rails-4e380828ffa8279740256164c6b83148cf0cbf13.zip
If the table behind has no primary key, do not ask again and just return nil.
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r--activerecord/lib/active_record/attribute_methods/primary_key.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb
index 16362acfe9..6eff716703 100644
--- a/activerecord/lib/active_record/attribute_methods/primary_key.rb
+++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -33,7 +33,8 @@ module ActiveRecord
# Defines the primary key field -- can be overridden in subclasses. Overwriting will negate any effect of the
# primary_key_prefix_type setting, though.
def primary_key
- @primary_key ||= reset_primary_key
+ @primary_key = reset_primary_key unless defined? @primary_key
+ @primary_key
end
# Returns a quoted version of the primary key name, used to construct SQL statements.