JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
Namespaced resources don't infer namespaced model_name
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.3k
- Forks
- 546
- PR merge metrics
- No merged PRs in 30d
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 ?
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.
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.
Assessment
- Tech stack
- rails, ruby
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100