Sha256: 16e417b642ff76eb6b6c4758931f7a41551e90bd8609eda649413dc639093fbe
Contents?: true
Size: 1006 Bytes
Versions: 2
Compression:
Stored size: 1006 Bytes
Contents
# The Errors class is planned to replace AM::Errors. It provides proper nested error messages. class Reform::Contract::Errors < ActiveModel::Errors def messages return super unless Reform.rails3_0? self end # def each # messages.each_key do |attribute| # self[attribute].each { |error| yield attribute, Array.wrap(error) } # end # end def merge!(errors, prefix) prefixes = prefix.join(".") # TODO: merge into AM. errors.messages.each do |field, msgs| field = (prefix+[field]).join(".").to_sym # TODO: why is that a symbol in Rails? msgs = [msgs] if Reform.rails3_0? # DISCUSS: fix in #each? msgs.each do |msg| next if messages[field] and messages[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 def valid? # TODO: test me in unit test. blank? end def to_s messages.inspect end end # Errors
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
reform-1.2.0.beta1 | lib/reform/contract/errors.rb |
reform-1.1.1 | lib/reform/contract/errors.rb |