Class: DataMapper::Validations::ValidationErrors
- Inherits:
-
Object
- Object
- DataMapper::Validations::ValidationErrors
- Defined in:
- lib/devise/orm/data_mapper/validations/dm-validations.rb
Overview
Monkey-patch ValidationErrors to support generation of error message from a Symbol. This does not translate, consistent with normal DataMapper operation. Set DataMapper::Validate::ValidationErrors.default_error_messages if alternate messages are needed (after devise has been initialized).
Instance Method Summary collapse
-
#add(field_name, message = nil, active_record_options = {}) ⇒ Object
If the message is a Symbol, allow
default_error_message
to generate the message, including translation. - #original_add ⇒ Object
-
#to_xml(options = {}) ⇒ Object
Some devise controller actions expect resource#errors to respond to #to_xml.
Instance Method Details
#add(field_name, message = nil, active_record_options = {}) ⇒ Object
If the message is a Symbol, allow default_error_message
to generate the message, including translation.
14 15 16 17 18 19 |
# File 'lib/devise/orm/data_mapper/validations/dm-validations.rb', line 14 def add(field_name, = nil, = {}) if .kind_of?(Symbol) = (field_name, , ) end original_add(field_name, ) unless errors[field_name].include?() end |
#original_add ⇒ Object
10 |
# File 'lib/devise/orm/data_mapper/validations/dm-validations.rb', line 10 alias_method :original_add, :add |
#to_xml(options = {}) ⇒ Object
Some devise controller actions expect resource#errors to respond to #to_xml. Otherwise, we get a Missing template error
23 24 25 |
# File 'lib/devise/orm/data_mapper/validations/dm-validations.rb', line 23 def to_xml( = {}) @errors.to_hash.to_xml(.merge(:root => 'errors')) end |