在尝试保存陈旧记录时引发。当记录在实例化后在另一个查询中保存时,记录就是陈旧的,例如,当两个用户编辑同一 wiki 页面,并且一个用户开始编辑并在另一个用户之前保存页面时。
在 ActiveRecord::Locking
模块文档中阅读有关乐观锁定的更多信息。
方法
- N
属性
[R] | attempted_action | |
[R] | record |
类公共方法
new(record = nil, attempted_action = nil) 链接
来源:显示 | 在 GitHub 上
# File activerecord/lib/active_record/errors.rb, line 353 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