JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Relationships on Create for non ActiveRecord models
まだ誰も着手していません。
- 主要言語
- Ruby
- スター
- 2.3k
- フォーク
- 546
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I guess more of a question.
I have this legacy app we are trying to slowly migrate to use jsonapi-resources. We have some bloated models we are splitting into smaller resources but also some models that point to Redis-backed models.
class RedisResource < JSONAPI::Resource
attribute :attr_1
attribute :attr_2
# Override required. The underlying model is not based on
# ActiveRecord.
def self.find_by_key(key, options = {})
context = options[:context]
model = RedisModel.find(key)
raise(JSONAPI::Exceptions::RecordNotFound, key) if model.nil?
new(model, context)
end
end
The problem though, is that somehow the relationship data is getting lost before reaching the Resource methods like: #replace_field(field_data).
All that info is available when I use an ActiveRecord model that uses the #belongs_to helper. But unsure what do I need to do/implement in my models to get the relationship assignment working.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
RedisResource#find_by_key から始め、ActiveRecord ではないリソースで、リレーションシップのデータがどのように #replace_field(field_data) に到達するかを追跡します。その経路を belongs_to を使用する ActiveRecord リソースの場合と比較します。Redis-backed モデルで issue のリレーションシップ割り当てが機能し、関連する動作がテストで検証されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- redis, ruby
- 領域
- api, backend
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100