diff options
| author | Matthew Draper <matthew@trebex.net> | 2017-03-19 09:31:02 +1030 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-19 09:31:02 +1030 | 
| commit | 00c4a16c08a8b31822d5d9a7753848940df777cf (patch) | |
| tree | edbcb1272aac6598abd22fa92ff24e9aa3402f2f /railties/lib/rails/generators | |
| parent | fd16e1a92feed73df70e140880cc17b6e482c846 (diff) | |
| parent | 4183ee882055f997fe61804ba43ee4c168b2477c (diff) | |
| download | rails-00c4a16c08a8b31822d5d9a7753848940df777cf.tar.gz rails-00c4a16c08a8b31822d5d9a7753848940df777cf.tar.bz2 rails-00c4a16c08a8b31822d5d9a7753848940df777cf.zip | |
Merge pull request #28469 from matthewd/new-new-defaults
Track the version-compatible config settings inside railties
Diffstat (limited to 'railties/lib/rails/generators')
4 files changed, 24 insertions, 37 deletions
| diff --git a/railties/lib/rails/generators/rails/app/app_generator.rb b/railties/lib/rails/generators/rails/app/app_generator.rb index 442258c9d1..38830ba38f 100644 --- a/railties/lib/rails/generators/rails/app/app_generator.rb +++ b/railties/lib/rails/generators/rails/app/app_generator.rb @@ -371,6 +371,14 @@ module Rails          end        end +      def delete_new_framework_defaults +        # Sprockets owns the only new default for 5.1: if it's disabled, +        # we don't want the file. +        unless options[:update] && !options[:skip_sprockets] +          remove_file "config/initializers/new_framework_defaults_5_1.rb" +        end +      end +        def delete_bin_yarn_if_skip_yarn_option          remove_file "bin/yarn" if options[:skip_yarn]        end diff --git a/railties/lib/rails/generators/rails/app/templates/config/application.rb b/railties/lib/rails/generators/rails/app/templates/config/application.rb index c0a0bd0a3e..d5d214052f 100644 --- a/railties/lib/rails/generators/rails/app/templates/config/application.rb +++ b/railties/lib/rails/generators/rails/app/templates/config/application.rb @@ -22,6 +22,9 @@ Bundler.require(*Rails.groups)  module <%= app_const_base %>    class Application < Rails::Application +    # Initialize configuration defaults for originally generated Rails version. +    config.load_defaults <%= Rails::VERSION::STRING.to_f %> +      # 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. 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 deleted file mode 100644 index bd844f0503..0000000000 --- a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults.rb.tt +++ /dev/null @@ -1,37 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file contains migration options to ease your Rails 5.0 upgrade. -# -<%- if options[:update] -%> -# Once upgraded flip defaults one by one to migrate to the new default. -# -<%- end -%> -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -<%- unless options[:api] -%> - -# Enable per-form CSRF tokens. Previous versions had false. -Rails.application.config.action_controller.per_form_csrf_tokens = <%= options[:update] ? false : true %> - -# Enable origin-checking CSRF mitigation. Previous versions had false. -Rails.application.config.action_controller.forgery_protection_origin_check = <%= options[:update] ? false : true %> -<%- end -%> - -# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. -# Previous versions had false. -ActiveSupport.to_time_preserves_timezone = <%= options[:update] ? false : true %> -<%- unless options[:skip_active_record] -%> - -# Require `belongs_to` associations by default. Previous versions had false. -Rails.application.config.active_record.belongs_to_required_by_default = <%= options[:update] ? false : true %> -<%- end -%> -<%- unless options[:update] -%> - -# Configure SSL options to enable HSTS with subdomains. Previous versions had false. -Rails.application.config.ssl_options = { hsts: { subdomains: true } } -<%- end -%> -<%- unless options[:skip_sprockets] -%> - -# Unknown asset fallback will return the path passed in when the given -# asset is not present in the asset pipeline. -Rails.application.config.assets.unknown_asset_fallback = <%= options[:update] ? true : false %> -<%- end -%> diff --git a/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt new file mode 100644 index 0000000000..5f5545c4c7 --- /dev/null +++ b/railties/lib/rails/generators/rails/app/templates/config/initializers/new_framework_defaults_5_1.rb.tt @@ -0,0 +1,13 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains migration options to ease your Rails 5.1 upgrade. +# +# Once upgraded flip defaults one by one to migrate to the new default. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +<%- unless options[:skip_sprockets] -%> + +# Unknown asset fallback will return the path passed in when the given +# asset is not present in the asset pipeline. +# Rails.application.config.assets.unknown_asset_fallback = false +<%- end -%> | 
