Exception: Mongoid::Errors::DocumentNotFound
- Inherits:
-
MongoidError
- Object
- StandardError
- MongoidError
- Mongoid::Errors::DocumentNotFound
- Defined in:
- lib/mongoid/errors/document_not_found.rb
Overview
Raised when querying the database for a document by a specific id which does not exist. If multiple ids were passed then it will display all of those.
Example:
DocumentNotFound.new(Person, ["1", "2"])
Constant Summary
Constants inherited from MongoidError
Instance Attribute Summary collapse
-
#identifiers ⇒ Object
readonly
Returns the value of attribute identifiers.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
-
#initialize(klass, ids) ⇒ DocumentNotFound
constructor
A new instance of DocumentNotFound.
Methods inherited from MongoidError
Constructor Details
#initialize(klass, ids) ⇒ DocumentNotFound
Returns a new instance of DocumentNotFound.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/mongoid/errors/document_not_found.rb', line 16 def initialize(klass, ids) @klass = klass @identifiers = ids.is_a?(Array) ? ids.join(", ") : ids super( translate( "document_not_found", { :klass => klass.name, :identifiers => @identifiers } ) ) end |
Instance Attribute Details
#identifiers ⇒ Object (readonly)
Returns the value of attribute identifiers.
14 15 16 |
# File 'lib/mongoid/errors/document_not_found.rb', line 14 def identifiers @identifiers end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
14 15 16 |
# File 'lib/mongoid/errors/document_not_found.rb', line 14 def klass @klass end |