class ActiveModel::Errors

def messages_for(attribute)

# => ["is too short (minimum is 5 characters)", "can't be blank"]
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