class JSONAPI::Exceptions::InvalidRelationship

Attributes

relationship_name[RW]
type[RW]

Public Class Methods

new(type, relationship_name, error_object_overrides = {}) click to toggle source
Calls superclass method JSONAPI::Exceptions::Error::new
# File lib/jsonapi/exceptions.rb, line 333
def initialize(type, relationship_name, error_object_overrides = {})
  @relationship_name = relationship_name
  @type = type
  super(error_object_overrides)
end

Public Instance Methods

errors() click to toggle source
# File lib/jsonapi/exceptions.rb, line 339
def errors
  [create_error_object(code: JSONAPI::INVALID_RELATIONSHIP,
                       status: :bad_request,
                       title: I18n.translate('jsonapi-resources.exceptions.invalid_relationship.title',
                                             default: 'Invalid relationship'),
                       detail: I18n.translate('jsonapi-resources.exceptions.invalid_relationship.detail',
                                              default: "#{relationship_name} is not a valid field for #{type}.",
                                              relationship_name: relationship_name, type: type))]
end