Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Rails 6 zeitwerk autoload problem with gem #36381
Steps to reproduce
I did ugrade rails 5.2 to 6.0. and zeitwerk autoload and use it.
My application use knock gem.
Zeitwork load class when const is use.
See the zeitwerk logs, autloader order is
Zeitwerk@rails.main: autoload set for UserTokenController, to be loaded from /user_token_controller.rb
Zeitwerk@rails.main: constant Knock::ApplicationController loaded from file /Users/ray/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/knock-2.1.1/app/controllers/knock/application_controller.rb
Zeitwerk@rails.main: constant Knock::AuthTokenController loaded from file /Users/ray/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/knock-2.1.1/app/controllers/knock/auth_token_controller.rb
Maybe, authTokenController is last called, and method in userTokenController can't override.
I think As a solution to the problem, all gem is load first time at once, and later application controllers load. (becuase gem is not changed in run time)
How about that? and if that correct, how to first load gem before load application controllers?
Call 'auth_params' in UserTokenController
Call 'auth_params' in Knock::AuthTokenController
Rails version: 6.0.0
Ruby version: 2.6.0
I creating a test project, and will share it when it is complete.