diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-15 05:44:07 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2017-06-15 05:44:07 +0900 |
commit | f5f7ca57da2a486b4d2493cb70479174f2968ada (patch) | |
tree | 437d4113b4244b3ec5b4025fb4ff3b1d37b490d6 /activerecord/lib/active_record/attribute_methods | |
parent | b81288541b6c8fe04082e4579e549bd71bc350dd (diff) | |
download | rails-f5f7ca57da2a486b4d2493cb70479174f2968ada.tar.gz rails-f5f7ca57da2a486b4d2493cb70479174f2968ada.tar.bz2 rails-f5f7ca57da2a486b4d2493cb70479174f2968ada.zip |
Prevent extra `sync_with_transaction_state`
`sync_with_transaction_state` in `to_key` is unneeded because `id` also
does.
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/primary_key.rb | 7 |
1 files 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 b5fd0cb370..b9b2acff37 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 ActiveRecord # 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. |