当尝试保存过时的记录时抛出。当记录在实例化后在另一个查询中被保存时,该记录即为过时,例如,当两个用户编辑同一个 wiki 页面,其中一个用户在另一个用户之前开始编辑并保存了该页面。
有关乐观锁定的更多信息,请参阅 ActiveRecord::Locking 模块文档。
方法
- N
Attributes
| [R] | attempted_action | |
| [R] | record |
类公共方法
new(record = nil, attempted_action = nil) 链接
来源: 显示 | 在 GitHub 上
# File activerecord/lib/active_record/errors.rb, line 381 def initialize(record = nil, attempted_action = nil) if record && attempted_action @record = record @attempted_action = attempted_action super("Attempted to #{attempted_action} a stale object: #{record.class.name}.") else super("Stale object error.") end end