嘗試儲存過時的記錄時引發。當在建立實體後,在另一個查詢中儲存記錄時,記錄會過時,例如,當兩個使用者編輯同一個 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