Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Namespaced resources don't infer namespaced model_name

Open
#1,152 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
rails, ruby
Domain
api, backend

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

  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.

More from JSONAPI-Resources/jsonapi-resources

All issues in JSONAPI-Resources/jsonapi-resources

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.