aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application/configuration.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-03-18 07:30:30 +1030
committerMatthew Draper <matthew@trebex.net>2017-03-18 07:30:30 +1030
commit4183ee882055f997fe61804ba43ee4c168b2477c (patch)
treecb1812aa43ba598a89540f9eca1cdd45c88fb4b3 /railties/lib/rails/application/configuration.rb
parent7413be0d31ec7eacc6f93e26546cb02ac6db73ca (diff)
downloadrails-4183ee882055f997fe61804ba43ee4c168b2477c.tar.gz
rails-4183ee882055f997fe61804ba43ee4c168b2477c.tar.bz2
rails-4183ee882055f997fe61804ba43ee4c168b2477c.zip
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.
Diffstat (limited to 'railties/lib/rails/application/configuration.rb')
-rw-r--r--railties/lib/rails/application/configuration.rb28
1 files changed, 28 insertions, 0 deletions
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