From 4183ee882055f997fe61804ba43ee4c168b2477c Mon Sep 17 00:00:00 2001 From: Matthew Draper Date: Sat, 18 Mar 2017 07:30:30 +1030 Subject: Track the version-compatible config settings inside railties Instead of forcing new applications to carry an initializer that just switches things to what their default "should" be, we can handle it internally. The initializer is then only used by upgraders: it shows what the new default would be (commented out), while their upgraded application continues to operate as it did before. Under this model, a multiply-upgraded application could accumulate several new_framework_defaults_*.rb files, for each release series it has traversed. A given release series only needs to generate the latest, though, because we don't support `rails app:upgrade` while skipping releases. --- railties/lib/rails/application/configuration.rb | 28 +++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'railties/lib/rails/application/configuration.rb') diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index b0592151b7..027207bbb2 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -55,6 +55,34 @@ module Rails @read_encrypted_secrets = false end + def load_defaults(target_version) + case target_version.to_s + when "5.0" + if defined?(action_controller) + action_controller.per_form_csrf_tokens = true + action_controller.forgery_protection_origin_check = true + end + + ActiveSupport.to_time_preserves_timezone = true + + if defined?(active_record) + active_record.belongs_to_required_by_default = true + end + + self.ssl_options = { hsts: { subdomains: true } } + + when "5.1" + load_defaults "5.0" + + if defined?(assets) + assets.unknown_asset_fallback = false + end + + else + raise "Unknown version #{target_version.to_s.inspect}" + end + end + def encoding=(value) @encoding = value silence_warnings do -- cgit v1.2.3