Namespaced resources don't infer namespaced model_name
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start at lib/jsonapi/resource.rb around line 925 and reproduce the Foo::Bar and Foo::BarResource example from the issue. The work is done when a resource defined inside a module infers the matching namespaced model without an explicit model_name and no MODEL NOT FOUND warning.
Written by the indexing model from the issue text.
Description
I don't know if this is by design or a bug, but given the follwing model and resource, the resource cannot infer the model name because of demodulize in https://github.com/cerebris/jsonapi-resources/blob/5af1f17068b66b0a17b7b69e5db334c640f6f34b/lib/jsonapi/resource.rb#L925
# model
module Foo
class Bar < ApplicationRecord
end
end
# resource
module Foo
class BarResource < JSONAPI::Resource
# model_name Foo::Bar' <= with this, things work fine, without, you'll get a warn "[MODEL NOT FOUND] warning
end
end
If the resource is defined inside a module, should't we prefix the model_name with the same module by default to permit model_name inferring ?
- Dominant language
- Ruby
- Stars
- 2.3k
- Forks
- 546
- PR merge metrics
- No merged PRs in 30d
Getting set up
We have not checked this project's setup files yet. Start from its README, and see our first-contribution guide for the general steps.
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
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
TheOdinProject/curriculum#31423 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
oxidize-rb/rb-sys#807 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day