instance method
include?
Ruby on Rails 6.0.6
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 142
def include?(attribute)
attribute = attribute.to_sym
messages.key?(attribute) && messages[attribute].present?
end
Defined in activemodel/lib/active_model/errors.rb line 142
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Errors