Exception: JSONAPI::Exceptions::HasManyRelationExists

Inherits:
Error
  • Object
show all
Defined in:
lib/jsonapi/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ HasManyRelationExists


101
102
103
# File 'lib/jsonapi/exceptions.rb', line 101

def initialize(id)
  @id = id
end

Instance Attribute Details

#idObject

Returns the value of attribute id


100
101
102
# File 'lib/jsonapi/exceptions.rb', line 100

def id
  @id
end

Instance Method Details

#errorsObject


105
106
107
108
109
110
111
112
113
# File 'lib/jsonapi/exceptions.rb', line 105

def errors
  [JSONAPI::Error.new(code: JSONAPI::RELATION_EXISTS,
                      status: :bad_request,
                      title: I18n.translate('jsonapi-resources.exceptions.has_many_relation.title',
                                            default: 'Relation exists'),
                      detail: I18n.translate('jsonapi-resources.exceptions.has_many_relation.detail',
                                             default: "The relation to #{id} already exists.",
                                             id: id))]
end