我发誓我已经阅读了这些文档,并且我认为我对这些原则有基本的了解,但我一生都无法弄清楚我在哪里不恰当地加载了这些常量。
我正在努力升级最初是 Rails 5.2 的应用程序
我在运行 RSpec、服务器、本地控制台等时收到此警告。
DEPRECATION WARNING: Initialization autoloaded the constants ApplicationHelper, EventsHelper, FontAwesome::Rails::IconHelper, DeviseHelper, ErrorHandler, and ApplicationController.
Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.
以下是不恰当地自动加载的常量:
- ApplicationHelper - 标准 Rails 文件
- EventsHelper - EventsController 的标准 Rails 文件
- FontAwesome::Rails::IconHelper -来自 gem,不在我的应用程序目录中
- DeviseHelper -来自 gem,不在我的应用程序目录中
- ErrorHandler -位于 'app/controllers/concerns/error_handler'
- ApplicationController -标准 Rails 文件
我已经寻找我可能正在调用的实例include
或require
这些常量,但没有找到。我特别关注我的初始化程序。
我已经运行(并通读)bin/rails zeitwerk:check
没有任何明显的提示。我看到这些实例按预期加载:
...
Zeitwerk@rails.main: constant ApplicationHelper loaded from file /Users/ckragt/ruby/filterbuildscheduler/app/helpers/application_helper.rb
...
Zeitwerk@rails.main: constant EventsHelper loaded from file /Users/ckragt/ruby/filterbuildscheduler/app/helpers/events_helper.rb
...
Zeitwerk@rails.main: constant FontAwesome::Rails::IconHelper loaded from file /Users/ckragt/.rvm/gems/ruby-2.7.0/gems/font-awesome-rails-4.7.0.7/app/helpers/font_awesome/rails/icon_helper.rb
...
Zeitwerk@rails.main: constant DeviseHelper loaded from file /Users/ckragt/.rvm/gems/ruby-2.7.0/gems/devise-4.7.3/app/helpers/devise_helper.rb
...
Zeitwerk@rails.main: constant ErrorHandler loaded from file /Users/ckragt/ruby/filterbuildscheduler/app/controllers/concerns/error_handler.rb
...
Zeitwerk@rails.main: autoload set for ApplicationController, to be loaded from /Users/ckragt/ruby/filterbuildscheduler/app/controllers/application_controller.rb
我正在使用 Spring 和 Binstub(都更新到最新版本)。
application.rb
这是我文件的顶部:
# frozen_string_literal: true
require_relative 'boot'
require 'csv'
require 'rails'
# Pick the frameworks you want:
require 'active_model/railtie'
require 'active_job/railtie'
require 'active_record/railtie'
# require "active_storage/engine"
require 'action_controller/railtie'
require 'action_mailer/railtie'
# require 'action_mailbox/engine'
# require 'action_text/engine'
require 'action_view/railtie'
# require 'action_cable/engine'
require 'sprockets/railtie'
# require 'rails/test_unit/railtie'
require 'google/apis/gmail_v1'
require 'google/api_client/client_secrets'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module BuildPlanner
class Application < Rails::Application
# Initialize configuration defaults for originally generated Rails version.
config.load_defaults 6.0
...
关于我应该在哪里看的任何想法?