From 2ba7355b007b58ea6d0ade6cdc36ff41b3aeff91 Mon Sep 17 00:00:00 2001 From: Julian Herrero Date: Thu, 4 Apr 2019 16:48:32 +0200 Subject: [PATCH] Add lib folder path to eager_load_paths Because autoloading is disabled in production with Rails 5, using autoload_paths will not load needed classes from specified paths. The solution to this, is to ask Rails to eager load classes. https://sipsandbits.com/2017/02/14/upgrading-a-ruby-on-rails-application/ --- config/environments/preproduction.rb | 2 +- config/environments/production.rb | 2 +- config/environments/staging.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/environments/preproduction.rb b/config/environments/preproduction.rb index 5dfdcacd6..78a443249 100644 --- a/config/environments/preproduction.rb +++ b/config/environments/preproduction.rb @@ -13,7 +13,7 @@ Rails.application.configure do # Because autoloading is disabled in production environments with Rails 5, # using autoload_paths will not load needed classes from specified paths. # The solution to this, is to ask Rails to eager load classes. - config.eager_load_paths << "#{config.root}/lib" + config.eager_load_paths += ["#{config.root}/lib"] # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false diff --git a/config/environments/production.rb b/config/environments/production.rb index d66dd3b3d..2972eb78f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -13,7 +13,7 @@ Rails.application.configure do # Because autoloading is disabled in production environments with Rails 5, # using autoload_paths will not load needed classes from specified paths. # The solution to this, is to ask Rails to eager load classes. - config.eager_load_paths << "#{config.root}/lib" + config.eager_load_paths += ["#{config.root}/lib"] # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 5a47275cc..8e64e9fae 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -13,7 +13,7 @@ Rails.application.configure do # Because autoloading is disabled in production environments with Rails 5, # using autoload_paths will not load needed classes from specified paths. # The solution to this, is to ask Rails to eager load classes. - config.eager_load_paths << "#{config.root}/lib" + config.eager_load_paths += ["#{config.root}/lib"] # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false