class ActiveModel::Errors

def to_hash(full_messages = false)

person.errors.to_hash(true) # => {:name=>["name cannot be nil"]}
person.errors.to_hash # => {:name=>["cannot be nil"]}

is +true+, it will contain full messages (see +full_message+).
Returns a Hash of attributes with their error messages. If +full_messages+
def to_hash(full_messages = false)
  message_method = full_messages ? :full_message : :message
  group_by_attribute.transform_values do |errors|
    errors.map(&message_method)
  end
end