'Rails render error code with jsonapi-rails

I want to render error code property, as JSON API specification describes, with jsonapi_errors method in jsonapi-rails gem. How could I set the code property in error object?

PS I'm using ActiveInteraction gem in combination with jsonapi-rails.



Solution 1:[1]

To render the error this syntax jsonapi-rails gem supports render jsonapi_errors: { detail: resource.errors.full_messages }, status: :unprocessable_entity.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Muhammad Awais