Class: Statinize::Errors

Inherits:
Hash show all
Defined in:
lib/statinize/errors.rb

Instance Method Summary collapse

Methods inherited from Hash

#deep_dup

Instance Method Details

#niceObject



13
14
15
16
17
18
19
20
21
# File 'lib/statinize/errors.rb', line 13

def nice
  nice_errors = map do |attr_name, errors|
    errors.map do |error|
      "#{attr_name.to_s.split("_").tap { |attr| attr.first.capitalize! }.join(" ")} #{error}"
    end.join("; ")
  end.join("; ")

  "ValidationError: #{nice_errors}"
end