Exception: ActiveRecord::StaleObjectError
- Inherits:
-
ActiveRecordError
- Object
- StandardError
- ActiveRecordError
- ActiveRecord::StaleObjectError
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/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 documentation.
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 = nil, attempted_action = nil) ⇒ StaleObjectError
constructor
A new instance of StaleObjectError.
Constructor Details
#initialize(record = nil, attempted_action = nil) ⇒ StaleObjectError
Returns a new instance of StaleObjectError.
283 284 285 286 287 288 289 290 291 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/errors.rb', line 283 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 |
Instance Attribute Details
#attempted_action ⇒ Object (readonly)
Returns the value of attribute attempted_action.
281 282 283 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/errors.rb', line 281 def attempted_action @attempted_action end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
281 282 283 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/active_record/errors.rb', line 281 def record @record end |