mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Eager load supports individual files
Also we want to eager load routes before anything else.
This commit is contained in:
parent
338c3c45fa
commit
6060a1d97b
2 changed files with 8 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue