JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

RecordNotFound should receive associated resource class

オープン
#747 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。