Class: ActiveModel::Errors
- Inherits:
-
Object
- Object
- ActiveModel::Errors
- Defined in:
- lib/rails_api_validation_errors/active_model_errors.rb
Constant Summary collapse
- @@translate_message =
Option to specify wether to return hash or translation. Defaults to true to keep original behaviour.
true
Class Method Summary collapse
Instance Method Summary collapse
-
#_generate_message ⇒ Object
Keep original method.
- #generate_message(attribute, type = :invalid, options = {}) ⇒ Object
Class Method Details
.disable_translations ⇒ Object
10 11 12 |
# File 'lib/rails_api_validation_errors/active_model_errors.rb', line 10 def self.disable_translations @@translate_message = false end |
.enable_translations ⇒ Object
14 15 16 |
# File 'lib/rails_api_validation_errors/active_model_errors.rb', line 14 def self.enable_translations @@translate_message = true end |
Instance Method Details
#_generate_message ⇒ Object
Keep original method
19 |
# File 'lib/rails_api_validation_errors/active_model_errors.rb', line 19 alias |
#generate_message(attribute, type = :invalid, options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/rails_api_validation_errors/active_model_errors.rb', line 21 def (attribute, type = :invalid, = {}) if @@translate_message (attribute, type, ) else type = .delete(:message) if [:message].is_a?(Symbol) { :message => type, :meta => } end end |