JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
RecordNotFound should receive associated resource class
オープン
まだ誰も着手していません。
Type: Enhancement
- 主要言語
- Ruby
- スター
- 2.3k
- フォーク
- 546
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
The message from record not found only pass ID as attribute.
I think it would be better to pass the resource class as well so that we can have something like
detail: I18n.translate('jsonapi-resources.exceptions.record_not_found.detail',
default: "The #{resource.name} identified by #{id} could not be found.", id: id, type: resource.class))]
Or maybe the associated activerecord class
This is the current implementation
class RecordNotFound < Error
attr_accessor :id
def initialize(id)
@id = id
end
def errors
[JSONAPI::Error.new(code: JSONAPI::RECORD_NOT_FOUND,
status: :not_found,
title: I18n.translate('jsonapi-resources.exceptions.record_not_found.title',
default: 'Record not found'),
detail: I18n.translate('jsonapi-resources.exceptions.record_not_found.detail',
default: "The record identified by #{id} could not be found.", id: id))]
end
end
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず RecordNotFound クラスとその呼び出し元をたどり、JSONAPI::Error の detail の翻訳と、issue に示されている record_not_found I18n キーに注目します。エラーが JSON:API リソースクラスと、それに関連付けられた ActiveRecord クラスのどちらを公開すべきかを明らかにし、その結果として得られる not-found メッセージに意図したリソースコンテキストと ID が含まれていることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rails, ruby
- 領域
- api, backend
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100