JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

How to create multi-level nested routes? (It expects 2nd level relationship to be at root level)

Open
#542 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

If I need multi-nested routes like:

GET /organizations/:org_id/users/:user_id/addresses/:address_id

When I get organizations I see the related link for /organization/:org_id/users, however when I get the user it's related link is /users/:user_id/addresses when I feel it should be
/organizations/:org_id/users/:user_id/addresses

Basically it expects the 2nd level relationship to be a route at the root level.

How to handle this?

Thanks.

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 reproducing the nested route example in the issue and inspect how relationship links are generated for organizations, users, and addresses. The expected result is that the address relationship preserves the full organization and user path; no file or test is identified in the issue, so the relevant route-generation entry point must first be located.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.