From e7758b8b68e33ca770fcedec0ae66e636276be08 Mon Sep 17 00:00:00 2001 From: Jonathan Boler Date: Mon, 4 Jun 2018 12:56:36 -0500 Subject: Eager load routes on rebuild --- railties/lib/rails/application/routes_reloader.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index 2ef09b4162..916988a651 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -7,7 +7,7 @@ module Rails class RoutesReloader attr_reader :route_sets, :paths attr_accessor :eager_load - delegate :updated?, to: :updater + delegate :execute_if_updated, :execute, :updated?, to: :updater def initialize @paths = [] @@ -19,23 +19,11 @@ module Rails clear! load_paths finalize! + route_sets.each(&:eager_load!) if eager_load ensure revert end - def execute - ret = updater.execute - route_sets.each(&:eager_load!) if eager_load - ret - end - - def execute_if_updated - if updated = updater.execute_if_updated - route_sets.each(&:eager_load!) if eager_load - end - updated - end - private def updater -- cgit v1.2.3 From 869ba3ec62aa3a440edda7c1af3276445b56546b Mon Sep 17 00:00:00 2001 From: Jonathan Boler Date: Tue, 19 Jun 2018 16:25:39 -0500 Subject: Only execute route updater once on app boot --- railties/lib/rails/application/finisher.rb | 2 +- railties/lib/rails/application/routes_reloader.rb | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index c4b188aeee..04aaf6dd9a 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -127,7 +127,7 @@ module Rails initializer :set_routes_reloader_hook do |app| reloader = routes_reloader reloader.eager_load = app.config.eager_load - reloader.execute_if_updated + reloader.execute reloaders << reloader app.reloader.to_run do # We configure #execute rather than #execute_if_updated because if diff --git a/railties/lib/rails/application/routes_reloader.rb b/railties/lib/rails/application/routes_reloader.rb index 916988a651..3ecb8e264e 100644 --- a/railties/lib/rails/application/routes_reloader.rb +++ b/railties/lib/rails/application/routes_reloader.rb @@ -27,11 +27,7 @@ module Rails private def updater - @updater ||= begin - updater = ActiveSupport::FileUpdateChecker.new(paths) { reload! } - updater.execute - updater - end + @updater ||= ActiveSupport::FileUpdateChecker.new(paths) { reload! } end def clear! -- cgit v1.2.3