diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2018-09-26 11:09:35 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2018-09-26 11:09:35 -0700 |
commit | 6060a1d97bc02a47d9f41d9dc3208a33c2a1a696 (patch) | |
tree | 6ea3d1b0987581733de86a5ec9e8030c9b969942 /railties | |
parent | 338c3c45fa4018e695453ccd3d73c4c9362fc007 (diff) | |
download | rails-6060a1d97bc02a47d9f41d9dc3208a33c2a1a696.tar.gz rails-6060a1d97bc02a47d9f41d9dc3208a33c2a1a696.tar.bz2 rails-6060a1d97bc02a47d9f41d9dc3208a33c2a1a696.zip |
Eager load supports individual files
Also we want to eager load routes before anything else.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/engine.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails/engine/configuration.rb | 2 |
2 files changed, 8 insertions, 4 deletions
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" |