Hi i am having a application built in rails 6 and i am trying to update it to rails 7 but there's some problem i am facing with zeitwerk.
in the rails admin initilizer
# initilizer/rails_admin.rb
require 'rails_admin/main_controller'
i am having above code. but it is giving me NameError: uninitialized constant RailsAdmin::ApplicationController
i tried require 'rails_admin/application_controller
but then i get uninitialized constant ApplicationController and then it goes on like i have to require everything which application controller is using
My rails admin version is 3.0.0 and ruby 3
This error is unrelated to Zeitwerk.
In Rails 6, autoloading reloadable code from the initializers was deprecated, and warnings were issued. These warnings were issued both in classic and in zeitwerk mode. This feature has been removed from Rails 7.
This is explained in the upgrading guide.
Controllers in Rails engines are reloadable, and therefore this new rule applies. Please decorate the controller in a to_prepare
block as documented in the autoloading guide.
Also, please do not issue require
calls for reloadable code, just use the RailsAdmin::MainController
constant directly.