JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Including Resources

Open
#389 16 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

I have a flash card app with the following object model:

card_set
    has_many :cards
    has_many :tags

card
    belongs_to :card_set
    habtm :tags

tag
    belongs_to :card_set
    habits :cards

I would like to include a card’s tags whenever a card is requested, and particularly when a card_set’s cards are requested.

What is the best way to do this? Is there any way to do this declaratively in the resource file (or elsewhere)?

The docs seem to point you towards using a ResourceSerializer and serialize_to_hash in the controller but trying this seemed a bit messy.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the resource file and the ResourceSerializer and serialize_to_hash paths mentioned in the issue. Trace how a card request and a card_set's cards are serialized, then determine how declarative inclusion should be represented. Done means requested cards include their tags without controller-specific serialization code.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.