From 6060a1d97bc02a47d9f41d9dc3208a33c2a1a696 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 26 Sep 2018 11:09:35 -0700 Subject: Eager load supports individual files Also we want to eager load routes before anything else. --- railties/lib/rails/engine.rb | 10 +++++++--- railties/lib/rails/engine/configuration.rb | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'railties') diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 6a13a84108..108d654ce3 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -473,9 +473,13 @@ module Rails # files inside eager_load paths. def eager_load! config.eager_load_paths.each do |load_path| - matcher = /\A#{Regexp.escape(load_path.to_s)}\/(.*)\.rb\Z/ - Dir.glob("#{load_path}/**/*.rb").sort.each do |file| - require_dependency file.sub(matcher, '\1') + if File.file?(load_path) + require_dependency load_path + else + matcher = /\A#{Regexp.escape(load_path.to_s)}\/(.*)\.rb\Z/ + Dir.glob("#{load_path}/**/*.rb").sort.each do |file| + require_dependency file.sub(matcher, '\1') + end end end end diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 6bf0406b21..7595272c03 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -38,6 +38,7 @@ module Rails @paths ||= begin paths = Rails::Paths::Root.new(@root) + paths.add "config/routes.rb", eager_load: true paths.add "app", eager_load: true, glob: "{*,*/concerns}" paths.add "app/assets", glob: "*" paths.add "app/controllers", eager_load: true @@ -55,7 +56,6 @@ module Rails paths.add "config/environments", glob: "#{Rails.env}.rb" paths.add "config/initializers", glob: "**/*.rb" paths.add "config/locales", glob: "*.{rb,yml}" - paths.add "config/routes.rb" paths.add "db" paths.add "db/migrate" -- cgit v1.2.3