123456789_123456789_123456789_123456789_123456789_

Exception: ActiveRecord::StaleObjectError

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveRecordError, StandardError
Instance Chain:
self, ActiveRecordError, StandardError
Inherits: ActiveRecord::ActiveRecordError
Defined in: activerecord/lib/active_record/errors.rb

Overview

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 Locking module documentation.

Class Method Summary

Instance Attribute Summary

Constructor Details

.new(record, attempted_action) ⇒ StaleObjectError

[ GitHub ]

  
# File 'activerecord/lib/active_record/errors.rb', line 128

def initialize(record, attempted_action)
  super("Attempted to #{attempted_action} a stale object: #{record.class.name}")
  @record = record
  @attempted_action = attempted_action
end

Instance Attribute Details

#attempted_action (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/errors.rb', line 126

attr_reader :record, :attempted_action

#record (readonly)

[ GitHub ]

  
# File 'activerecord/lib/active_record/errors.rb', line 126

attr_reader :record, :attempted_action