From 629bc03bf885f8d1450a28972c5bea630a079e85 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Fri, 22 Jun 2012 12:42:32 -0500 Subject: [PATCH] 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 --- activemodel/lib/active_model/errors.rb | 4 ++-- 1 file 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?