Skip to content

Add helper/util method for rendering an object's errors? #6

@mecampbellsoup

Description

@mecampbellsoup

It's very common to see a pattern like this in a Rails controller (I'm using jsonapi-utils methods in the code):

if model.save
  jsonapi_render json: model
else
  jsonapi_render json: model.errors # doesn't work
end

Seems like this gem should expose a helper for this type of failed POST request, e.g. jsonapi_render_unprocessable model.errors which would serve 422 response with a response body listing the reasons why the model couldn't be written to the DB.

Not sure what JSONAPI spec says about this, however...

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions