From 53ddd046d996fb83e22d7c5fe52ea89dd9358d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Fri, 4 Sep 2020 14:45:44 +0200 Subject: [PATCH] Add "load_defaults" method and undo what it does The goal here is to have a notion on what the defaults are in a Rails 5 application, know why our application is working in a different way (it's because these defaults aren't loaded in an application which was originally developed using Rails 4), and have an explicit list of things we are overwriting. Furthermore, running the `app:update` rake task to upgrade to Rails 5.2 will by default add the line loading default options for Rails 5.0, so by adopting those default options we prevent accidental mistakes when upgrading. We'll have to review these items and see which ones can be changed to their default values for Rails 5 applications. --- config/application.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/config/application.rb b/config/application.rb index b137dd5f6..6747e0880 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,9 +8,14 @@ Bundler.require(*Rails.groups) module Consul class Application < Rails::Application - # 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. + config.load_defaults 5.0 + + # Overwrite Rails 5.0 defaults and use the options we used in Rails 4 + config.action_controller.per_form_csrf_tokens = nil + config.action_controller.forgery_protection_origin_check = nil + ActiveSupport.to_time_preserves_timezone = false + config.active_record.belongs_to_required_by_default = false + config.ssl_options = {} # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.