Method: ActiveModel::Errors#include?
- Defined in:
- activemodel/lib/active_model/errors.rb
#include?(attribute) ⇒ Boolean Also known as: has_key?, key?
Returns true if the error messages include an error for the given key attribute, false otherwise.
person.errors. # => {:name=>["cannot be nil"]}
person.errors.include?(:name) # => true
person.errors.include?(:age) # => false
202 203 204 205 206 |
# File 'activemodel/lib/active_model/errors.rb', line 202 def include?(attribute) @errors.any? { |error| error.match?(attribute.to_sym) } end |