Rails (Zeitwerk Mode) DEPRECATION WARNING: Initialization autoloaded the constant ApplicationHelper

charlie_hsieh · 2021年11月04日 · 最后由 zhengpd 回复于 2021年11月05日 · 218 次阅读

请问有人遇到过这个 warning ?

DEPRECATION WARNING: Initialization autoloaded the constant ApplicationHelper

貌似 很多 code 都有受到影响。

https://guides.rubyonrails.org/autoloading_and_reloading_constants.html

In order to autoload safely at boot time, please wrap your code in a reloader
callback this way:

    Rails.application.reloader.to_prepare do
      # Autoload classes and modules needed at boot time here.
    end

rails 初始化过程中 autoload 的 ApplicationHelper,在改了文件触发 reload 之后的 ApplicationHelper 可能不一致,大概是这个问题

需要 登录 后方可回复, 如果你还没有账号请 注册新账号