class ActiveModel::Errors

def group_by_attribute

# => {:name=>[<#ActiveModel::Error>, <#ActiveModel::Error>]}
person.errors.group_by_attribute

Returns a Hash of attributes with an array of their Error objects.
def group_by_attribute
  @errors.group_by(&:attribute)
end