Exception: ActiveRecord::SoleRecordExceeded
- Inherits:
-
ActiveRecordError
- Object
- StandardError
- ActiveRecordError
- ActiveRecord::SoleRecordExceeded
- Defined in:
- activerecord/lib/active_record/errors.rb
Overview
Raised when Active Record finds multiple records but only expected one.
Instance Attribute Summary collapse
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(record = nil) ⇒ SoleRecordExceeded
constructor
A new instance of SoleRecordExceeded.
Constructor Details
#initialize(record = nil) ⇒ SoleRecordExceeded
Returns a new instance of SoleRecordExceeded.
153 154 155 156 |
# File 'activerecord/lib/active_record/errors.rb', line 153 def initialize(record = nil) @record = record super "Wanted only one #{record&.name || "record"}" end |
Instance Attribute Details
#record ⇒ Object (readonly)
Returns the value of attribute record
151 152 153 |
# File 'activerecord/lib/active_record/errors.rb', line 151 def record @record end |