Use _read_attribute(primary_key) instead of id

This will avoid the indirection of having calling id since we already
know which is the primary key column.

Also this will make explicit the behavior since it is not clear that id
gets the right primary key value and not just the value of the "id"
column.
This commit is contained in:
Rafael Mendonça França 2015-04-19 17:14:08 -04:00
parent 9721b45b40
commit b584cc68fc
1 changed files with 1 additions and 1 deletions

View File

@ -479,7 +479,7 @@ module ActiveRecord
clear_attribute_changes(changes.keys)
primary_key = self.class.primary_key
scope = self.class.unscoped.where(primary_key => id)
scope = self.class.unscoped.where(primary_key => _read_attribute(primary_key))
if locking_enabled?
locking_column = self.class.locking_column