diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-03-27 17:18:44 -0300 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2014-03-27 17:18:44 -0300 |
commit | 5cf456a076034a03f645d7465e1ebd683bc06907 (patch) | |
tree | 0dda6ec739e88dede1b8b6d7dc9a89c232fe86c7 /activemodel | |
parent | bdab7b15d12bdfec37b399cee9a889510a221d22 (diff) | |
parent | d93bfac207c258167257676035c9b0b2912fba5c (diff) | |
download | rails-5cf456a076034a03f645d7465e1ebd683bc06907.tar.gz rails-5cf456a076034a03f645d7465e1ebd683bc06907.tar.bz2 rails-5cf456a076034a03f645d7465e1ebd683bc06907.zip |
Merge pull request #14505 from davefp/patch-1
Adds explanation of :base attribute to errors.add [ci skip]
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 9c3bc913e1..917d3b9142 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -289,6 +289,13 @@ module ActiveModel # # => NameIsInvalid: name is invalid # # person.errors.messages # => {} + # + # +attribute+ should be set to <tt>:base</tt> if the error is not + # directly associated with a single attribute. + # + # person.errors.add(:base, "either name or email must be present") + # person.errors.messages + # # => {:base=>["either name or email must be present"]} def add(attribute, message = :invalid, options = {}) message = normalize_message(attribute, message, options) if exception = options[:strict] |