From f5f7ca57da2a486b4d2493cb70479174f2968ada Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Thu, 15 Jun 2017 05:44:07 +0900 Subject: [PATCH] Prevent extra `sync_with_transaction_state` `sync_with_transaction_state` in `to_key` is unneeded because `id` also does. --- .../lib/active_record/attribute_methods/primary_key.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb index b5fd0cb3700f7..b9b2acff37bfc 100644 --- a/activerecord/lib/active_record/attribute_methods/primary_key.rb +++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb @@ -8,17 +8,14 @@ module PrimaryKey # Returns this record's primary key value wrapped in an array if one is # available. def to_key - sync_with_transaction_state key = id [key] if key end # Returns the primary key value. def id - if pk = self.class.primary_key - sync_with_transaction_state - _read_attribute(pk) - end + sync_with_transaction_state + _read_attribute(self.class.primary_key) if self.class.primary_key end # Sets the primary key value.