Load Rails /lib subdirectories in production26 Nov 2021 - Tobias Erdle
When I add code to my app which I may want to extract later, I like to place it within
RAILS_ROOT/lib inside some subdirectory like
To get the content of those directories loaded, the
config/application.rb needs to be extended like this:
class Application < Rails::Application ... config.eager_load_paths << Rails.root.join('/lib/logging') end
With this setting enabled, the application will recognize the classes when loaded with
config.eager_load = true, which is used most of the time in staging and production environments.