aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/lib/active_model/errors.rb2
-rw-r--r--activemodel/lib/active_model/validations/with.rb4
-rw-r--r--activemodel/test/cases/errors_test.rb1
3 files changed, 4 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 71ece15b71..1cf8144e98 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -86,7 +86,7 @@ module ActiveModel
# Do the error messages include an error with key +error+?
def include?(error)
- messages.include? error
+ (v = messages[error]) && v.any?
end
# Get messages for +key+
diff --git a/activemodel/lib/active_model/validations/with.rb b/activemodel/lib/active_model/validations/with.rb
index 65ae18a769..a87b213fe4 100644
--- a/activemodel/lib/active_model/validations/with.rb
+++ b/activemodel/lib/active_model/validations/with.rb
@@ -101,7 +101,7 @@ module ActiveModel
# class Person
# include ActiveModel::Validations
#
- # validates :instance_validations
+ # validate :instance_validations
#
# def instance_validations
# validates_with MyValidator
@@ -116,7 +116,7 @@ module ActiveModel
# class Person
# include ActiveModel::Validations
#
- # validates :instance_validations, :on => :create
+ # validate :instance_validations, :on => :create
#
# def instance_validations
# validates_with MyValidator, MyOtherValidator
diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb
index a24cac40ad..85ca8ca835 100644
--- a/activemodel/test/cases/errors_test.rb
+++ b/activemodel/test/cases/errors_test.rb
@@ -38,6 +38,7 @@ class ErrorsTest < ActiveModel::TestCase
person.errors[:foo]
assert person.errors.empty?
assert person.errors.blank?
+ assert !person.errors.include?(:foo)
end
test "method validate! should work" do