LoginSignup
0
0

More than 1 year has passed since last update.

Rails 6.0~ DEPRECATION WARNING: Initialization autoloaded the constants MyClass.消した。

Last updated at Posted at 2020-11-25

rails6.0からzeitwerkモードで定数の読み込みを行うようになりました。
https://railsguides.jp/autoloading_and_reloading_constants.html
それに起因してサーバーを起動した際に以下のようなwarningがログに出力されるようになりました。
このwarning邪魔なので消したいなあと思っていたところ、無事解決することができたのでその時の対応と考察を雑記します。

DEPRECATION WARNING: Initialization autoloaded the constants MyClass.

結論から述べると、原因はinitializersディレクトリで自ら定義した定数(MyClass)を読み込んでいたことでしたのでそれを他のディレクトリに移動させました。

自ら定義した定数はリロード時に変更を反映できる方が開発の便宜上良いので、initializersで読み込むことは非推奨なのだと考えました。(initializerディレクトリはサーバー初期化時のみ読み込まれる)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0