Skip to content

fix autoload deprecation warning #458

@donrestarone

Description

@donrestarone
solutions_sidekiq    | 2022-04-23T03:39:25.183Z pid=1 tid=gmo8hx245 WARN: DEPRECATION WARNING: Initialization autoloaded the constants EmberCliRailsAssetsHelper, ApplicationHelper, ApiClientsHelper, ApiFormsHelper, ApiNamespacesHelper, ApiResourcesHelper, ContentHelper, DashboardHelper, MessagesHelper, SearchHelper, SigninWizardHelper, SignupWizardHelper, SimpleDiscussion::ForumPostsHelper, SimpleDiscussion::ForumThreadsHelper, SubdomainHelper, UsersHelper, EmberRailsHelper, LocalTimeHelper, Comfy, Comfy::Admin, Comfy::Admin::CmsHelper, Comfy::CmsHelper, DeviseHelper, and ApplicationController.
solutions_sidekiq    |
solutions_sidekiq    | Being able to do this is deprecated. Autoloading during initialization is going
solutions_sidekiq    | to be an error condition in future versions of Rails.
solutions_sidekiq    |
solutions_sidekiq    | Reloading does not reboot the application, and therefore code executed during
solutions_sidekiq    | initialization does not run again. So, if you reload EmberCliRailsAssetsHelper, for example,
solutions_sidekiq    | the expected changes won't be reflected in that stale Module object.
solutions_sidekiq    |
solutions_sidekiq    | These autoloaded constants have been unloaded.
solutions_sidekiq    |
solutions_sidekiq    | In order to autoload safely at boot time, please wrap your code in a reloader
solutions_sidekiq    | callback this way:
solutions_sidekiq    |
solutions_sidekiq    |     Rails.application.reloader.to_prepare do
solutions_sidekiq    |       # Autoload classes and modules needed at boot time here.
solutions_sidekiq    |     end
solutions_sidekiq    |
solutions_sidekiq    | That block runs when the application boots, and every time there is a reload.
solutions_sidekiq    | For historical reasons, it may run twice, so it has to be idempotent.
solutions_sidekiq    |
solutions_sidekiq    | Check the "Autoloading and Reloading Constants" guide to learn more about how
solutions_sidekiq    | Rails autoloads and reloads.
solutions_sidekiq    |  (called from <top (required)> at /var/app/config/environment.rb:5)

Research:

  1. https://ryanfb.github.io/etc/2021/06/25/diagnosing_rails_6_deprecation_warning_-initialization_autoloaded_the_constants.html
  2. https://bill.harding.blog/2021/07/22/rails-6-1-deprecation-warning-initialization-autoloaded-the-constants-what-to-do-about-it/

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions