JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Relationship routes are created without adding them in the routes.rb

Open
#361 9 comments 0 reactions 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've defined the following Resource:

class CommentResource < BaseResource
      has_one :activity
      has_one :user
end

 class ActivityResource < BaseResource
      has_many :comments
end

jsonapi_resources :activities, only: %w(index show)
jsonapi_resources :comments, only: %w(create destroy index show)

And checking with rake routes I see that it also created all the relationship/related routes for both Activity and Comment even if I haven't added jsonapi_links / jsonapi_related_resources in the routes file

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 with the resource declarations and the routes.rb configuration shown in the issue, then reproduce the output with rake routes. Trace how relationship and related routes are generated for ActivityResource and CommentResource. Done means the route list matches the relationship declarations and the explicitly configured route options.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Bug
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.