Exception: ActiveRecord::StaleObjectError
- Inherits:
-
ActiveRecordError
- Object
- StandardError
- ActiveRecordError
- ActiveRecord::StaleObjectError
- Defined in:
- 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
-
#attempted_action ⇒ Object
readonly
Returns the value of attribute attempted_action.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(record, attempted_action) ⇒ StaleObjectError
constructor
A new instance of StaleObjectError.
- #message ⇒ Object
Constructor Details
#initialize(record, attempted_action) ⇒ StaleObjectError
Returns a new instance of StaleObjectError.
104 105 106 107 |
# File 'lib/active_record/errors.rb', line 104 def initialize(record, attempted_action) @record = record @attempted_action = attempted_action end |
Instance Attribute Details
#attempted_action ⇒ Object (readonly)
Returns the value of attribute attempted_action.
102 103 104 |
# File 'lib/active_record/errors.rb', line 102 def attempted_action @attempted_action end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
102 103 104 |
# File 'lib/active_record/errors.rb', line 102 def record @record end |
Instance Method Details
#message ⇒ Object
109 110 111 |
# File 'lib/active_record/errors.rb', line 109 def "Attempted to #{attempted_action} a stale object: #{record.class.name}" end |