diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-06-22 12:42:32 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-06-22 12:42:32 -0500 |
commit | 629bc03bf885f8d1450a28972c5bea630a079e85 (patch) | |
tree | 3d9a4535629711a0041c010e05ac063e89f7e23d | |
parent | 35ee8fa3d8b3ad49179f86af2bec2e53af335ac9 (diff) | |
download | rails-629bc03bf885f8d1450a28972c5bea630a079e85.tar.gz rails-629bc03bf885f8d1450a28972c5bea630a079e85.tar.bz2 rails-629bc03bf885f8d1450a28972c5bea630a079e85.zip |
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
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index aba6618b56..6307477145 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -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? |