Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 694 Bytes

autoload.md

File metadata and controls

21 lines (16 loc) · 694 Bytes

Auto Loading

Starting with Rails 6, Rails ships with a new and better way to autoload, which delegates to the Zeitwerk gem. We have an initializer for core_ext so we don't want to autoload it in config/application.rb. We also don't want to autoload assets, generators, etc.

# Rails < 7.1
# config/application.rb
config.autoload_paths << "#{Rails.root}/lib"
config.eager_load_paths << "#{Rails.root}/lib"

%w(assets core_ext generators middleware tasks templates).each do |subdir|
  Rails.autoloaders.main.ignore("#{Rails.root}/lib/#{subdir}")
end
# Rails 7.1+
# config/application.rb
config.autoload_lib(ignore: %w(assets core_ext tasks generators templates))