Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

jsonapi_resource should use relationship.class_name instead of relationship_name

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

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
rails, ruby
領域
api, backend

調査の方向性

まず issue 内のリレーション定義から始め、関連リソースの route kudos-received がどのように controller を選択するかを追跡します。リレーション名を class_name および model_name と比較し、デフォルトのルーティングでモデル名を使用するべきか、リレーション単位で controller のオーバーライドをサポートするべきかを判断します。生成された route が既存の動作を壊さず、意図した mm/kudos controller を対象にすれば完了です。

索引モデルが issue の本文から書いたものです。

説明

We have models Contractor and Mm::Kudo and corresponding resources.

class ContractorResource < JSONAPI::Resource
  model_name 'Coworker'
  attributes :name, :uid, :avatar_url

  has_many :kudos_given, class_name: 'Mm::Kudo'
end

class Mm::KudoResource < JSONAPI::Resource
  model_name 'Mm::Kudo'
  attributes :value, :tags, :comment

  has_one :giver, class_name: 'Contractor'
end

And generate route for kudos-received relation points to kudos#get_related_resources controller instead of mm/kudos#get_related_resources (btw.: includes work fine)

There two options:

  1. leave the default behaviour as it is and allow to overwrite controller at relationship level

e.g.: for the given example

  has_many :kudos_given, class_name: 'Mm::Kudo', controller: 'mm/kudos'

and pass the relationship params to the jsonapi_related_resources

  1. use model_name to generate path for default controller (and still allow to overwrite controller at the has_many definition

Which option should we pick and adopt

主要言語
Ruby
スター
2.3k
フォーク
546
PR マージ指標
30日以内にマージされた PR はありません

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

JSONAPI-Resources/jsonapi-resources のほかの issue

JSONAPI-Resources/jsonapi-resources の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

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

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