Exception: ActiveRecord::StaleObjectError

Inherits:
ActiveRecordError show all
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 ActiveRecord::Locking module RDoc.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (StaleObjectError) initialize(record, attempted_action)

Returns a new instance of StaleObjectError



109
110
111
112
113
# File 'activerecord/lib/active_record/errors.rb', line 109

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

- (Object) attempted_action (readonly)

Returns the value of attribute attempted_action



107
108
109
# File 'activerecord/lib/active_record/errors.rb', line 107

def attempted_action
  @attempted_action
end

- (Object) record (readonly)

Returns the value of attribute record



107
108
109
# File 'activerecord/lib/active_record/errors.rb', line 107

def record
  @record
end