instance method
include?
Ruby on Rails 8.1.2
Since v3.1.12Signature
include?(attribute)
Returns true if the error messages include an error for the given key attribute, false otherwise.
person.errors.messages # => {:name=>["cannot be nil"]} person.errors.include?(:name) # => true person.errors.include?(:age) # => false
Parameters
-
attributereq
Source
# File activemodel/lib/active_model/errors.rb, line 199
def include?(attribute)
@errors.any? { |error|
error.match?(attribute.to_sym)
}
end
Defined in activemodel/lib/active_model/errors.rb line 199
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Errors