jsonapi_resource should use relationship.class_name instead of relationship_name
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start with the relationship definitions in the issue and trace how the kudos-received related-resource route selects its controller. Compare the relationship name with class_name and model_name, then decide whether default routing should use the model name or support a relationship-level controller override; done means the generated route targets the intended mm/kudos controller without breaking existing behavior.
Written by the indexing model from the issue text.
Description
We have models Contractor and Mm::Kudo and corresponding resources.
class ContractorResource < JSONAPI::Resource
model_name 'Coworker'
attributes :name, :uid, :avatar_url
has_many :kudos_given, class_name: 'Mm::Kudo'
end
class Mm::KudoResource < JSONAPI::Resource
model_name 'Mm::Kudo'
attributes :value, :tags, :comment
has_one :giver, class_name: 'Contractor'
end
And generate route for kudos-received relation points to kudos#get_related_resources controller instead of mm/kudos#get_related_resources (btw.: includes work fine)
There two options:
- leave the default behaviour as it is and allow to overwrite controller at relationship level
e.g.: for the given example
has_many :kudos_given, class_name: 'Mm::Kudo', controller: 'mm/kudos'
and pass the relationship params to the jsonapi_related_resources
- use
model_nameto generate path for default controller (and still allow to overwrite controller at thehas_manydefinition
Which option should we pick and adopt
- Dominant language
- Ruby
- Stars
- 2.3k
- Forks
- 546
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JSONAPI-Resources/jsonapi-resources
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
Difficulty 3/5 1-2 days Newbie friendliness 50/100
JSONAPI-Resources/jsonapi-resources#1488 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
JSONAPI-Resources/jsonapi-resources#1479 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
JSONAPI-Resources/jsonapi-resources#1477 · 3 comments · 1 reaction ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
All issues in JSONAPI-Resources/jsonapi-resources
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
ai-generated
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hanami/hanami-cli#449 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
hanami/hanami-router#310 ·