NameError: uninitialized constant JSONAPI::ResourceController in Rails 7.1
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
lib/jsonapi-resources.rb の 12〜18 行目と、app/controllers/jsonapi/v1/base_controller.rb で使用されているロードパスから始めます。Ruby 3.3.6 および Rails 7.1.5.1 で、test/controllers/jsonapi/v1/team_projects_controller_test.rb を通じて断続的な失敗を再現します。eager loading や報告されている controller の workaround を必要とせず、テストスイートで未初期化定数のエラーが発生しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
This issue is a (choose one):
- Problem/bug report.
- Feature request.
- Request for support. Note: Please try to avoid submitting issues for support requests. Use Gitter instead.
Checklist before submitting:
- I've searched for an existing issue.
- I've NOT asked my question on Gitter because Gitter seems to be abandoned by the core team. There a lots of questions posted there that have no responses at all.
- I've included a complete bug report template. This step helps us and allows us to see the bug without trying to reproduce the problem from your description. It helps you because you will frequently detect if it's a problem specific to your project.
- The feature I'm asking for is compliant with the JSON:API spec.
Description
In trying to update to Rails 7.1 I'm running into random instances of this error when running my test suite.
Error:
Jsonapi::V1::TeamProjectsControllerTest#test_should_not_create_for_a_forbidden_team:
NameError: uninitialized constant JSONAPI::ResourceController
app/controllers/jsonapi/v1/base_controller.rb:3:in `<main>'
app/controllers/jsonapi/v1/team_projects_controller.rb:1:in `<main>'
test/controllers/jsonapi/v1/team_projects_controller_test.rb:126:in `block in <class:TeamProjectsControllerTest>'
Sometimes there will be 2 of them, other times 20 or 30.
Via some trial and error I discovered that if I alter my BaseController to look like this:
class Jsonapi::V1::BaseController < ActionController::Base
include JSONAPI::ActsAsResourceController
# ...
end
Instead of this:
class Jsonapi::V1::BaseController < JSONAPI::ResourceController
# ...
end
then the random errors go away.
I also noticed that these errors were only happening locally, and not in CI, and so I tried setting config.eager_load = true in config/environments/test.rb which also made the errors go away.
I poked around this gem a little bit and I think that this block of code isn't exactly working as expected in Rail 7.1.
Ruby: 3.3.6
Rails: 7.1.5.1
- 主要言語
- Ruby
- スター
- 2.3k
- フォーク
- 546
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
JSONAPI-Resources/jsonapi-resources のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 50/100
JSONAPI-Resources/jsonapi-resources#1488 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
JSONAPI-Resources/jsonapi-resources#1479 · コメント 2 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
JSONAPI-Resources/jsonapi-resources#1477 · コメント 3 件 · リアクション 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
JSONAPI-Resources/jsonapi-resources の issue をすべて見る
似ている issue
-
バグ
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
voxpupuli/puppet-epel#186 · コメント 1 件 ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) オープンBug Frontend
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
TheOdinProject/curriculum#31402 · コメント 1 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100