From 6ea4b55658122e9937f202eaa409ec3e7af94d80 Mon Sep 17 00:00:00 2001 From: rhymes Date: Tue, 28 May 2019 23:30:05 +0200 Subject: [PATCH] Require only used parts of Rails (#2988) Rails by defaults loads all its railties and engines, the current app does not use neither ActiveStorage, nor ActionCable nor TestUnit. We can, hence, dispense of them. --- config/application.rb | 14 +++++++++++++- config/environments/test.rb | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/config/application.rb b/config/application.rb index c245af705..6f02599a1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,18 @@ require_relative "boot" -require "rails/all" +# only require Rails parts that we actually use, this shaves off some memory +# ActiveStorage, ActionCable and TestUnit are not currently used by the app +# see +%w[ + active_record/railtie + action_controller/railtie + action_view/railtie + action_mailer/railtie + active_job/railtie + sprockets/railtie +].each do |railtie| + require railtie +end # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. diff --git a/config/environments/test.rb b/config/environments/test.rb index aef37d547..ef74d908d 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -31,7 +31,7 @@ Rails.application.configure do config.action_controller.allow_forgery_protection = false # Store uploaded files on the local file system in a temporary directory - config.active_storage.service = :test + # config.active_storage.service = :test config.action_mailer.perform_caching = false