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.
This commit is contained in:
Javi Martín
2020-09-04 14:45:44 +02:00
parent 937638f281
commit 53ddd046d9

View File

@@ -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.