class ActiveModel::Errors

def each

end
# then yield :name and "must be specified"
# Will yield :name and "can't be blank"
person.errors.each do |attribute, error|
person.errors.add(:name, :not_specified, message: "must be specified")

end
# Will yield :name and "can't be blank"
person.errors.each do |attribute, error|
person.errors.add(:name, :blank, message: "can't be blank")

has more than one error message, yields once for each error message.
Yields the attribute and the error for that attribute. If the attribute
Iterates through each error key, value pair in the error messages hash.
def each
  messages.each_key do |attribute|
    messages[attribute].each { |error| yield attribute, error }
  end
end