aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application
diff options
context:
space:
mode:
Diffstat (limited to 'railties/lib/rails/application')
-rw-r--r--railties/lib/rails/application/bootstrap.rb12
-rw-r--r--railties/lib/rails/application/configuration.rb13
-rw-r--r--railties/lib/rails/application/default_middleware_stack.rb1
-rw-r--r--railties/lib/rails/application/dummy_erb_compiler.rb5
-rw-r--r--railties/lib/rails/application/finisher.rb12
-rw-r--r--railties/lib/rails/application/routes_reloader.rb1
6 files changed, 26 insertions, 18 deletions
diff --git a/railties/lib/rails/application/bootstrap.rb b/railties/lib/rails/application/bootstrap.rb
index 50685a4d7a..1fdc7b2d71 100644
--- a/railties/lib/rails/application/bootstrap.rb
+++ b/railties/lib/rails/application/bootstrap.rb
@@ -34,20 +34,12 @@ module Rails
# Initialize the logger early in the stack in case we need to log some deprecation.
initializer :initialize_logger, group: :all do
Rails.logger ||= config.logger || begin
- path = config.paths["log"].first
- unless File.exist? File.dirname path
- FileUtils.mkdir_p File.dirname path
- end
-
- f = File.open path, "a"
- f.binmode
- f.sync = config.autoflush_log # if true make sure every write flushes
-
- logger = ActiveSupport::Logger.new f
+ logger = ActiveSupport::Logger.new(config.default_log_file)
logger.formatter = config.log_formatter
logger = ActiveSupport::TaggedLogging.new(logger)
logger
rescue StandardError
+ path = config.paths["log"].first
logger = ActiveSupport::TaggedLogging.new(ActiveSupport::Logger.new(STDERR))
logger.level = ActiveSupport::Logger::WARN
logger.warn(
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb
index 0b758dd3dd..72c7ff169f 100644
--- a/railties/lib/rails/application/configuration.rb
+++ b/railties/lib/rails/application/configuration.rb
@@ -129,6 +129,7 @@ module Rails
if respond_to?(:action_dispatch)
action_dispatch.use_cookies_with_metadata = true
+ action_dispatch.return_only_media_type_on_content_type = false
end
if respond_to?(:action_mailer)
@@ -311,6 +312,18 @@ module Rails
end
end
+ def default_log_file
+ path = paths["log"].first
+ unless File.exist? File.dirname path
+ FileUtils.mkdir_p File.dirname path
+ end
+
+ f = File.open path, "a"
+ f.binmode
+ f.sync = autoflush_log # if true make sure every write flushes
+ f
+ end
+
class Custom #:nodoc:
def initialize
@configurations = Hash.new
diff --git a/railties/lib/rails/application/default_middleware_stack.rb b/railties/lib/rails/application/default_middleware_stack.rb
index 9800b19274..3659c0ac3a 100644
--- a/railties/lib/rails/application/default_middleware_stack.rb
+++ b/railties/lib/rails/application/default_middleware_stack.rb
@@ -79,7 +79,6 @@ module Rails
end
private
-
def load_rack_cache
rack_cache = config.action_dispatch.rack_cache
return unless rack_cache
diff --git a/railties/lib/rails/application/dummy_erb_compiler.rb b/railties/lib/rails/application/dummy_erb_compiler.rb
index c4659123bb..028e790292 100644
--- a/railties/lib/rails/application/dummy_erb_compiler.rb
+++ b/railties/lib/rails/application/dummy_erb_compiler.rb
@@ -11,9 +11,8 @@ end
class DummyCompiler < ERB::Compiler # :nodoc:
def compile_content(stag, out)
- case stag
- when "<%="
- out.push "_erbout << 'dummy_compiler'"
+ if stag == "<%="
+ out.push "_erbout << ''"
end
end
end
diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb
index 109c560c80..9f4009ad20 100644
--- a/railties/lib/rails/application/finisher.rb
+++ b/railties/lib/rails/application/finisher.rb
@@ -39,8 +39,14 @@ module Rails
example = autoloaded.first
example_klass = example.constantize.class
- ActiveSupport::DescendantsTracker.clear
- ActiveSupport::Dependencies.clear
+ if config.autoloader == :zeitwerk
+ ActiveSupport::DescendantsTracker.clear
+ ActiveSupport::Dependencies.clear
+
+ unload_message = "#{these} autoloaded #{constants} #{have} been unloaded."
+ else
+ unload_message = "`config.autoloader` is set to `#{config.autoloader}`. #{these} autoloaded #{constants} would have been unloaded if `config.autoloader` had been set to `:zeitwerk`."
+ end
ActiveSupport::Deprecation.warn(<<~WARNING)
Initialization autoloaded the #{constants} #{enum}.
@@ -52,7 +58,7 @@ module Rails
initialization does not run again. So, if you reload #{example}, for example,
the expected changes won't be reflected in that stale #{example_klass} object.
- #{these} autoloaded #{constants} #{have} been unloaded.
+ #{unload_message}
Please, check the "Autoloading and Reloading Constants" guide for solutions.
WARNING
diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb
index 3ecb8e264e..1070362253 100644
--- a/railties/lib/rails/application/routes_reloader.rb
+++ b/railties/lib/rails/application/routes_reloader.rb
@@ -25,7 +25,6 @@ module Rails
end
private
-
def updater
@updater ||= ActiveSupport::FileUpdateChecker.new(paths) { reload! }
end