diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 9bb45aa3b7a8acc437f18650918c948477f588b7..ae1c326d956661a9e1e547dd6ff1dd049d34af92 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -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