class ActiveModel::Errors
def messages_for(attribute)
person.errors.messages_for(:name)
person = Person.create()
end
validates_length_of :name, in: 5..30
validates_presence_of :name, :email
class Person
Returns all the error messages for a given attribute in an array.
def messages_for(attribute) where(attribute).map(&:message) end