From 9b55d0fa1a6a67f4f18c013708c23662f72d680d Mon Sep 17 00:00:00 2001 From: Jonathon Date: Tue, 3 Dec 2024 16:47:38 +0000 Subject: [PATCH] Enable Rails 7.2 defaults flag Also enables autoloading for the lib directory which is now enforced in Zeitwerk and effective in Rails 7.2. --- Gemfile.lock | 1 - config/application.rb | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c95f24f941d..760a250147b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -230,7 +230,6 @@ GEM rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.6.1) - logger (1.6.1) logstasher (2.1.5) activesupport (>= 5.2) request_store diff --git a/config/application.rb b/config/application.rb index bcc176d14e9..f35b08c7948 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,9 +25,16 @@ class Application < Rails::Application include GovukPublishingComponents::AppHelpers::AssetHelper # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 7.2 config.govuk_time_zone = "London" + Rails.application.config.action_view.form_with_generates_remote_forms = false + # Custom directories with classes and modules you want to be autoloadable. + config.autoload_paths += %W[#{config.root}/lib #{config.root}/app/presenters] + + # New for rails 7.1 to enable previous autoload behaviour + config.add_autoload_paths_to_load_path = true + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. @@ -37,6 +44,7 @@ class Application < Rails::Application config.i18n.enforce_available_locales = false config.i18n.default_locale = :"en-GB" config.i18n.fallbacks = true + config.i18n.load_path += Dir[Rails.root.join("config/locales/**/*.yml")] # Path within public/ where assets are compiled to config.assets.prefix = "/assets/smartanswers" @@ -49,7 +57,15 @@ class Application < Rails::Application # Version of your assets, change this if you want to expire all your assets config.assets.version = "1.0" + + # Disable Rack::Cache + config.action_dispatch.rack_cache = nil + config.action_dispatch.ignore_accept_header = true + + # Force lib autoload, which was removed by Rails 3.0 and enforced by Zeitwerk + config.eager_load_paths << Rails.root.join("lib") + # Allow requests for all domains e.g. .dev.gov.uk config.hosts.clear # Please, add to the `ignore` list any other `lib` subdirectories that do