JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Error with aliased attr's into dasherized strings- Unable to update record with "no implicit conversion of nil into Hash" error
オープン
まだ誰も着手していません。
- 主要言語
- Ruby
- スター
- 2.3k
- フォーク
- 546
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I am running into an issue when attempting to save records with properties that have been aliased into a dasherized string.
I have a model like this:
# models/location.rb
class Location < ApplicationRecord
alias_attribute :numberOfColors, :number_of_colors__c
end
And my resource:
# resources/location_resource.rb:
class LocationResource < JSONAPI::Resource
attributes :numberOfColors
end
Sending a patch request like so returns the error no implicit conversion of nil into Hash.
{
"data":{
"id":"somerecordid",
"attributes":{
"colors": 3,
},
"type":"locations"
}
}
- If I skip the aliasing and pass in the attr as
number-of-colors--ceverything works as expected. - If I name the attr
colorseverything works as expected.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず models/location.rb と resources/location_resource.rb を使って PATCH リクエストを再現し、次に issue で説明されている動作する非エイリアスのケースと、エイリアス化された dasherized 属性を比較します。nil-to-Hash エラーを特定できるまで属性の更新経路を追跡します。エイリアス経由でエラーなく保存でき、既存の動作するケースが維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- rails, ruby
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100