Class: JSONAPI::ErrorSerializer

Inherits:
Object
  • Object
show all
Includes:
Serializer
Defined in:
lib/jsonapi/error_serializer.rb

Overview

A simple error serializer

Direct Known Subclasses

ActiveModelErrorSerializer

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.id_from_record(_record, _params) ⇒ NilClass

Overwrite the ID extraction method, to skip validations

Returns:

  • (NilClass)


20
21
# File 'lib/jsonapi/error_serializer.rb', line 20

def self.id_from_record(_record, _params)
end

Instance Method Details

#serializable_hashHash

Remap the root key to ‘errors`

Returns:

  • (Hash)


26
27
28
# File 'lib/jsonapi/error_serializer.rb', line 26

def serializable_hash
  { errors: (super[:data] || []).map { |error| error[:attributes] } }
end