Closed arefaslani closed 6 years ago
You should create such an object that would look like the following: for example error handling that occurs when Devise::RegistrationsController#create
def render_create_error
error = {detail: resource_errors[:full_messages][0]}
render jsonapi_errors: error
end
{
"errors": [
{
"detail": "Email has already been taken"
}
],
"jsonapi": {
"version": "1.0"
}
}
@arefaslani In order for the source
to be properly populated using the default serializer, you should deserialize the payload using deserializable_resource
(it is possible to avoid that but it needs a bit more work).
@beauby I will be thankful for your help if you can clarify the point of deserializing the payload while we are actually serializing the object.
Tnaks
I use ActiveInteraction gem with Rails API and jsonapi-rails gem for creating my JSON API. My problem is when I render errors using jsonapi_errors, the source of the error response is empty. How should I fill this field? This is the response: