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.
上级 9721b45b
......@@ -479,7 +479,7 @@ def touch(*names, time: nil)
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册