Skip to Content Skip to Search
v7.1.0
class ActiveRecord::StaleObjectError < ActiveRecord::ActiveRecordError

ActiveRecord::StaleObjectError

Raised on attempt to save stale record. Record is stale when it’s being saved in another query after instantiation, for example, when two users edit the same wiki page and one starts editing and saves the page before the other.

Read more about optimistic locking in ActiveRecord::Locking module documentation.

Methods
N

Attributes

[R] attempted_action
[R] record

Public class methods

new(record = nil, attempted_action = nil)

Permalink
Source code GitHub
# File activerecord/lib/active_record/errors.rb, line 352
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
Definition files