aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods/read.rb
diff options
context:
space:
mode:
authornamusyaka <namusyaka@gmail.com>2017-02-08 00:41:56 +0900
committernamusyaka <namusyaka@gmail.com>2017-02-09 01:57:50 +0900
commit3df9117abc7980c54df675503409d9bdcddc1fee (patch)
tree5dcdeb89934e04b4a53a624b912e2f3699afc149 /activerecord/lib/active_record/attribute_methods/read.rb
parent47113df0341cd7bf56056bc666527978c586c7c5 (diff)
downloadrails-3df9117abc7980c54df675503409d9bdcddc1fee.tar.gz
rails-3df9117abc7980c54df675503409d9bdcddc1fee.tar.bz2
rails-3df9117abc7980c54df675503409d9bdcddc1fee.zip
Fix inspection behavior when the :id column is not primary key
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/read.rb')
-rw-r--r--activerecord/lib/active_record/attribute_methods/read.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb
index 369a6e35aa..fdc4bf6621 100644
--- a/activerecord/lib/active_record/attribute_methods/read.rb
+++ b/activerecord/lib/active_record/attribute_methods/read.rb
@@ -54,7 +54,7 @@ module ActiveRecord
attr_name.to_s
end
- name = self.class.primary_key if name == "id".freeze
+ name = self.class.primary_key if name == "id".freeze && self.class.primary_key
_read_attribute(name, &block)
end