Adds explanation of :base attribute to errors.add
[ci skip]
This commit is contained in:
parent
bdab7b15d1
commit
d93bfac207
|
@ -289,6 +289,13 @@ module ActiveModel
|
||||||
# # => NameIsInvalid: name is invalid
|
# # => NameIsInvalid: name is invalid
|
||||||
#
|
#
|
||||||
# person.errors.messages # => {}
|
# 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 = {})
|
def add(attribute, message = :invalid, options = {})
|
||||||
message = normalize_message(attribute, message, options)
|
message = normalize_message(attribute, message, options)
|
||||||
if exception = options[:strict]
|
if exception = options[:strict]
|
||||||
|
|
Loading…
Reference in New Issue