Exception: Mongoid::Errors::MongoidError
- Defined in:
- lib/mongoid/errors/mongoid_error.rb
Overview
Default parent Mongoid error for all custom errors. This handles the base key for the translations and provides the convenience method for translating the messages.
Direct Known Subclasses
DocumentNotFound, InvalidCollection, InvalidDatabase, InvalidField, InvalidOptions, InvalidType, MixedRelations, TooManyNestedAttributeRecords, UnsavedDocument, UnsupportedVersion, Validations, MultiParameterAttributes::Errors::AttributeAssignmentError, MultiParameterAttributes::Errors::MultiparameterAssignmentErrors
Constant Summary collapse
- BASE_KEY =
"mongoid.errors.messages"
Instance Method Summary collapse
-
#translate(key, options) ⇒ Object
Given the key of the specific error and the options hash, translate the message.
Instance Method Details
#translate(key, options) ⇒ Object
Given the key of the specific error and the options hash, translate the message.
Options:
key: The key of the error in the locales. options: The objects to pass to create the message.
Returns:
A localized error message string.
22 23 24 |
# File 'lib/mongoid/errors/mongoid_error.rb', line 22 def translate(key, ) ::I18n.translate("#{BASE_KEY}.#{key}", ) end |