diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2018-07-03 14:04:04 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-03 14:04:04 -0400 |
commit | cfc48d0b5f363cc880237d2e25598c64c9eb8400 (patch) | |
tree | 4905823bed1da2a4670b05f4fc46f8c9e319ce60 | |
parent | eaef4b64fc90b24ee91496a894a60cadc27c0906 (diff) | |
parent | 869ba3ec62aa3a440edda7c1af3276445b56546b (diff) | |
download | rails-cfc48d0b5f363cc880237d2e25598c64c9eb8400.tar.gz rails-cfc48d0b5f363cc880237d2e25598c64c9eb8400.tar.bz2 rails-cfc48d0b5f363cc880237d2e25598c64c9eb8400.zip |
Merge pull request #33054 from jboler/master
Fix route eager loading
-rw-r--r-- | actionpack/lib/action_dispatch/journey/routes.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/application/finisher.rb | 2 | ||||
-rw-r--r-- | railties/lib/rails/application/routes_reloader.rb | 22 |
3 files changed, 5 insertions, 20 deletions
diff --git a/actionpack/lib/action_dispatch/journey/routes.rb b/actionpack/lib/action_dispatch/journey/routes.rb index 3ba8361d77..c0377459d5 100644 --- a/actionpack/lib/action_dispatch/journey/routes.rb +++ b/actionpack/lib/action_dispatch/journey/routes.rb @@ -56,6 +56,7 @@ module ActionDispatch end def simulator + return if ast.nil? @simulator ||= begin gtg = GTG::Builder.new(ast).transition_table GTG::Simulator.new(gtg) 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 2ef09b4162..3ecb8e264e 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,31 +19,15 @@ 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 - @updater ||= begin - updater = ActiveSupport::FileUpdateChecker.new(paths) { reload! } - updater.execute - updater - end + @updater ||= ActiveSupport::FileUpdateChecker.new(paths) { reload! } end def clear! |