JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources
NameError: uninitialized constant JSONAPI::ResourceController in Rails 7.1
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Ruby
- Estrellas
- 2.3k
- Forks
- 546
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con las líneas 12-18 de lib/jsonapi-resources.rb y la ruta de carga utilizada por app/controllers/jsonapi/v1/base_controller.rb. Reproduce el fallo intermitente mediante test/controllers/jsonapi/v1/team_projects_controller_test.rb con Ruby 3.3.6 y Rails 7.1.5.1. Se considera terminado cuando el conjunto de pruebas ya no genera el error de constante no inicializada sin requerir eager loading ni la solución alternativa indicada para el controlador.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- rails, ruby
- Área
- api, backend
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100