Class: Reform::Form::Errors
- Inherits:
-
ActiveModel::Errors
- Object
- ActiveModel::Errors
- Reform::Form::Errors
- Defined in:
- lib/reform/form.rb
Overview
The Errors class is planned to replace AM::Errors. It provides proper nested error messages.
Instance Method Summary collapse
-
#merge!(errors, prefix = nil) ⇒ Object
def each messages.each_key do |attribute| self.each { |error| yield attribute, Array.wrap(error) } end end.
- #messages ⇒ Object
Instance Method Details
#merge!(errors, prefix = nil) ⇒ Object
def each
messages.each_key do |attribute|
self[attribute].each { |error| yield attribute, Array.wrap(error) }
end
end
249 250 251 252 253 254 255 256 257 258 259 260 261 |
# File 'lib/reform/form.rb', line 249 def merge!(errors, prefix=nil) # TODO: merge into AM. errors..each do |field, msgs| field = "#{prefix}.#{field}" if prefix msgs = [msgs] if Reform.rails3_0? # DISCUSS: fix in #each? msgs.each do |msg| next if [field] and [field].include?(msg) add(field, msg) end # Forms now contains a plain errors hash. the errors for each item are still available in item.errors. end end |