diff options
-rw-r--r-- | actionview/lib/action_view/cache_expiry.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/application/finisher.rb | 12 |
2 files changed, 11 insertions, 3 deletions
diff --git a/actionview/lib/action_view/cache_expiry.rb b/actionview/lib/action_view/cache_expiry.rb index 3d8ffeaefb..7cdc2e9982 100644 --- a/actionview/lib/action_view/cache_expiry.rb +++ b/actionview/lib/action_view/cache_expiry.rb @@ -22,6 +22,8 @@ module ActionView def clear_cache_if_necessary @mutex.synchronize do watched_dirs = dirs_to_watch + return if watched_dirs.empty? + if watched_dirs != @watched_dirs @watched_dirs = watched_dirs @watcher = @watcher_class.new([], watched_dirs) do 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 |