JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Issue with namespaced resource

Open
#1,071 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'm running into difficulty with STI models and their corresponding resources.

I have a base model Event, with subclasses Events::Applied, Events::Interview (amongst others) and I'm not sure how to set up the resources. Currently I have an Api::V1::EventResource and Api::V1::Events::AppliedResource and Api::V1::Events::InterviewResource (both of which subclass the EventResource, however I'm getting an error NameError (JSONAPI: Could not find resource 'events/applied'. (Class Events::AppliedResource not found)) - it appears that my base namespace Api::V1 isn't being taken into account?

I'm also not sure how to handle model inheritance as a whole when it comes to JSONAPI::Resources. I'd like to have the base resource for index actions (immutable) and the subclass resources for create/updates (as well as index/show). Does this fit the pattern correctly? I'm certainly open to suggestions.

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

The issue names no files, tests, or entry points. Start by tracing JSONAPI::Resources resource lookup for the shown namespaced STI models and reviewing how inherited resources are resolved. Done means determining whether the namespace and inheritance arrangement is supported, or documenting the required resource setup and reproducing the result.

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.