Permalink
Browse files

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
  • Loading branch information...
1 parent 35ee8fa commit 629bc03bf885f8d1450a28972c5bea630a079e85 Francesco Rodriguez committed Jun 22, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 activemodel/lib/active_model/errors.rb
@@ -87,8 +87,8 @@ def clear
end
# Do the error messages include an error with key +error+?
@splattael
splattael Jun 25, 2012 Contributor

In the docs +error+ should read +attribute+

@splattael
splattael Jun 25, 2012 Contributor

Uh oh, I didn't see that commit. Sorry for the noise :-(

- def include?(error)
- (v = messages[error]) && v.any?
+ def include?(attribute)
+ (v = messages[attribute]) && v.any?
end
alias :has_key? :include?

0 comments on commit 629bc03

Please sign in to comment.