1
0
Fork 0
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:
Francesco Rodriguez 2012-06-22 12:42:32 -05:00
parent 35ee8fa3d8
commit 629bc03bf8

View file

@ -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?