Sha256: c3e5ab616cd03b94e7f5270f1257ef9a70a69ec3a7636c18f2cefc57ac2233a6

Contents?: true

Size: 436 Bytes

Versions: 4

Compression:

Stored size: 436 Bytes

Contents

if @errors.is_a?(Hash)
  errors = @errors.map {|field, errors|
    [field, errors.ensure_array.first]
  }

  json.errors errors do |(field, error)|
    json.code 422
    json.title "Bad Attribute"
    json.field field
    error += "." unless error.end_with?(".")
    json.detail error.capitalize
  end
else
  json.errors @errors.ensure_array do |error|
    json.code 422
    json.title "Unknown Attribute"
    json.field error
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
apes-1.0.3 views/errors/422.json.jbuilder
apes-1.0.2 views/errors/422.json.jbuilder
apes-1.0.1 views/errors/422.json.jbuilder
apes-1.0.0 views/errors/422.json.jbuilder