Module: FatFreeCRM::ActiveModel::Errors
- Defined in:
- lib/fat_free_crm/errors.rb
Class Method Summary collapse
-
.included(base) ⇒ Object
Override ActiveModel::Errors#each so we could display validation errors as is without rendering the attribute name.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
Override ActiveModel::Errors#each so we could display validation errors as is without rendering the attribute name. Simply place a caret as the first character of the error message.
This feature was handled by ‘advanced_errors’ plugin in Rails 2.x version of Fat Free CRM.
29 30 31 32 33 |
# File 'lib/fat_free_crm/errors.rb', line 29 def self.included(base) base.class_eval do alias_method :each, :each_with_explicit_error end end |
Instance Method Details
#each_with_explicit_error ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fat_free_crm/errors.rb', line 35 def each_with_explicit_error keys.each do |attribute| self[attribute].each do |error| if error.start_with?('^') yield :base, error[1..-1] # Drop the attribute. else yield attribute, error # This is default Rails3 behavior. end end end end |