mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
change param name to improve documentation
The keys of the error messages are actually attribute names. It makes the documentation easier to understand: # Returns +true+ if the error messages include an error for the given # +attribute+, +false+ otherwise. # # person.errors.messages # => { :name => ["can not be nil"] } # person.errors.include?(:name) # => true # person.errors.include?(:age) # => false def include?(attribute) (v = messages[attribute]) && v.any? end
This commit is contained in:
parent
35ee8fa3d8
commit
629bc03bf8
1 changed files with 2 additions and 2 deletions
|
@ -87,8 +87,8 @@ module ActiveModel
|
|||
end
|
||||
|
||||
# Do the error messages include an error with key +error+?
|
||||
def include?(error)
|
||||
(v = messages[error]) && v.any?
|
||||
def include?(attribute)
|
||||
(v = messages[attribute]) && v.any?
|
||||
end
|
||||
alias :has_key? :include?
|
||||
|
||||
|
|
Loading…
Reference in a new issue