あるプロジェクトを Rails 6 にアップグレードしたら、DEPRECATION WARNING が出るようになりました。
DEPRECATION WARNING: Initialization autoloaded the constants ApplicationHelper, AaaHelper, BbbHelper, ..., ActionText::ContentHelper, and ActionText::TagHelper.
ApplicationHelper で grep する
なるほど〜。これは、例の Zeitwerk のワーニングだなとピンと来た私は、
config/initializers
内のファイルとかで ApplicationHelper
を参照しているのかと思い、ApplicationHelper
で grep してみたのでした。
すんなり解決できるかと探してみましたが、 app/helpers/application_helper.rb
以外に
ApplicationHelper
と書いて使っているところなんてどこにも見つからない...。
何が悪いの?
Rails の ISSUE を見つける
Google で検索してみたところ、 Rails の ISSUEが見つかりました。
zeitwerk doesn't autoreload the helpers
まさにここに書いてある通り
OmniAuth.config.on_failure = XxxxController.action(:failure)
としてました。
これを参考にして、
OmniAuth.config.after_initialize do
OmniAuth.config.on_failure = XxxxController.action(:failure)
end
に修正することで解消できました。