I've upgraded one of my apps from Rails 4.2.6 to Rails 5.0.0. The Upgrade Guide says, that the Autoload feature is now disabled in production by default.
Now I always get an error on my production server since I load all lib files with autoload in the application.rb
file.
module MyApp
class Application < Rails::Application
config.autoload_paths += %W( lib/ )
end
end
For now, I've set the config.enable_dependency_loading
to true
but I wonder if there is a better solution to this. There must be a reason that Autoloading is disabled in production by default.
Autoloading is disabled in the production environment because of thread safety. Thank you to @Зелёный for the link.
I solved this problem by storing the lib files in a lib
folder in my app
directory as recommended on Github. Every folder in the app
folder gets loaded by Rails automatically.