Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adds explanation of :base attribute to errors.add

[ci skip]
  • Loading branch information...
commit d93bfac207c258167257676035c9b0b2912fba5c 1 parent bdab7b1
@davefp davefp authored
Showing with 7 additions and 0 deletions.
  1. +7 −0 activemodel/lib/active_model/errors.rb
View
7 activemodel/lib/active_model/errors.rb
@@ -289,6 +289,13 @@ def to_hash(full_messages = false)
# # => 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]
Please sign in to comment.
Something went wrong with that request. Please try again.