Class: Api::BaseApiController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Api::BaseApiController
- Defined in:
- lib/voyage/templates/api_base_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
Instance Method Details
#respond_with_errors(object) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/voyage/templates/api_base_controller.rb', line 12 def respond_with_errors(object) serialized_errors = object.errors..map do |field, errors| errors.map do || { status: 422, source: { pointer: "/data/attributes/#{field}" }, detail: , } end end.flatten render json: { errors: serialized_errors }, status: :unprocessable_entity end |