aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPrathamesh Sonpatki <csonpatki@gmail.com>2016-06-01 07:47:42 -0400
committerPrathamesh Sonpatki <csonpatki@gmail.com>2016-06-04 11:03:04 -0400
commitb362ef9cb54a21fe23eda82539097a59c61af607 (patch)
tree2348da5d85ced070d8b317dcebed8ffdab2f0400 /railties
parent0ddcade928741886ad2ac1bd0273c3ce28a5e1e1 (diff)
downloadrails-b362ef9cb54a21fe23eda82539097a59c61af607.tar.gz
rails-b362ef9cb54a21fe23eda82539097a59c61af607.tar.bz2
rails-b362ef9cb54a21fe23eda82539097a59c61af607.zip
More cleanup of new framework defaults
- Move real new default options to the top of the file. - After that club together all the options which were added to keep backward compatibility. So all of them will get only one header. - Based on https://github.com/rails/rails/pull/25231#issuecomment-222945173.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt30
1 files changed, 12 insertions, 18 deletions
diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt
index 730938a1ba..438627e601 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt
+++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt
@@ -1,18 +1,6 @@
# Be sure to restart your server when you modify this file.
# This file contains all the new default configuration options from
# Rails 5.0.
-<%- unless options[:skip_active_record] -%>
-
-# Require `belongs_to` associations by default. This is a new Rails 5.0
-# default, so it is introduced as a configuration option to ensure that apps
-# made on earlier versions of Rails are not affected when upgrading.
-Rails.application.config.active_record.belongs_to_required_by_default = true
-<%- end -%>
-
-# Do not halt callback chains when a callback returns false. This is a new
-# Rails 5.0 default, so it is introduced as a configuration option to ensure
-# that apps made with earlier versions of Rails are not affected when upgrading.
-ActiveSupport.halt_callback_chains_on_return_false = false
<%- unless options[:api] -%>
# Enable per-form CSRF tokens.
@@ -22,16 +10,22 @@ Rails.application.config.action_controller.per_form_csrf_tokens = true
Rails.application.config.action_controller.forgery_protection_origin_check = true
<%- end -%>
-# Configure SSL options to enable HSTS with subdomains. This is a new
-# Rails 5.0 default, so it is introduced as a configuration option to ensure
-# that apps made on earlier versions of Rails are not affected when upgrading.
+# Following config options are introduced to ensure that apps
+# made on earlier versions of Rails are not affected when upgrading.
+<%- unless options[:skip_active_record] -%>
+
+# Require `belongs_to` associations by default.
+Rails.application.config.active_record.belongs_to_required_by_default = true
+<%- end -%>
+
+# Do not halt callback chains when a callback returns false.
+ActiveSupport.halt_callback_chains_on_return_false = false
+
+# Configure SSL options to enable HSTS with subdomains.
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
# Preserve the timezone of the receiver when calling to `to_time`.
# Ruby 2.4 will change the behavior of `to_time` to preserve the timezone
# when converting to an instance of `Time` instead of the previous behavior
# of converting to the local system timezone.
-#
-# Rails 5.0 introduced this config option so that apps made with earlier
-# versions of Rails are not affected when upgrading.
ActiveSupport.to_time_preserves_timezone = true