aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application/configuration.rb
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/application/configuration.rb')
-rw-r--r--railties/lib/rails/application/configuration.rb40
1 files changed, 33 insertions, 7 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index b0592151b7..7c49fabba5 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -14,9 +14,8 @@ module Rails
:ssl_options, :public_file_server,
:session_options, :time_zone, :reload_classes_only_on_change,
:beginning_of_week, :filter_redirect, :x, :enable_dependency_loading,
- :read_encrypted_secrets
+ :read_encrypted_secrets, :log_level
- attr_writer :log_level
attr_reader :encoding, :api_only
def initialize(*)
@@ -35,7 +34,7 @@ module Rails
@session_store = nil
@time_zone = "UTC"
@beginning_of_week = :monday
- @log_level = nil
+ @log_level = :debug
@generators = app_generators
@cache_store = [ :file_store, "#{root}/tmp/cache/" ]
@railties_order = [:all]
@@ -55,6 +54,37 @@ module Rails
@read_encrypted_secrets = false
end
+ def load_defaults(target_version)
+ case target_version.to_s
+ when "5.0"
+ if respond_to?(:action_controller)
+ action_controller.per_form_csrf_tokens = true
+ action_controller.forgery_protection_origin_check = true
+ end
+
+ ActiveSupport.to_time_preserves_timezone = true
+
+ if respond_to?(: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 respond_to?(:assets)
+ assets.unknown_asset_fallback = false
+ end
+
+ when "5.2"
+ load_defaults "5.1"
+
+ else
+ raise "Unknown version #{target_version.to_s.inspect}"
+ end
+ end
+
def encoding=(value)
@encoding = value
silence_warnings do
@@ -121,10 +151,6 @@ module Rails
raise e, "Cannot load `Rails.application.database_configuration`:\n#{e.message}", e.backtrace
end
- def log_level
- @log_level ||= (Rails.env.production? ? :info : :debug)
- end
-
def colorize_logging
ActiveSupport::LogSubscriber.colorize_logging
end