mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Add all folders in app/* to the load path
This commit is contained in:
@@ -23,8 +23,8 @@ module Rails
|
||||
# the load_once paths.
|
||||
initializer :set_autoload_paths do
|
||||
require 'active_support/dependencies'
|
||||
ActiveSupport::Dependencies.load_paths = config.load_paths.uniq
|
||||
ActiveSupport::Dependencies.load_once_paths = config.load_once_paths.uniq
|
||||
ActiveSupport::Dependencies.load_paths = expand_load_path(config.load_paths)
|
||||
ActiveSupport::Dependencies.load_once_paths = expand_load_path(config.load_once_paths)
|
||||
|
||||
extra = ActiveSupport::Dependencies.load_once_paths - ActiveSupport::Dependencies.load_paths
|
||||
unless extra.empty?
|
||||
@@ -140,7 +140,7 @@ module Rails
|
||||
end
|
||||
end
|
||||
|
||||
initializer :initialize_notifications do
|
||||
initializer :initialize_notifications do
|
||||
require 'active_support/notifications'
|
||||
|
||||
if config.colorize_logging == false
|
||||
@@ -152,5 +152,10 @@ module Rails
|
||||
Rails::Subscriber.dispatch(args)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def expand_load_path(load_paths)
|
||||
load_paths.map { |path| Dir.glob(path.to_s) }.flatten.uniq
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -200,12 +200,7 @@ module Rails
|
||||
end
|
||||
|
||||
def eager_load_paths
|
||||
@eager_load_paths ||= %w(
|
||||
app/metal
|
||||
app/models
|
||||
app/controllers
|
||||
app/helpers
|
||||
).map { |dir| "#{root}/#{dir}" }.select { |dir| File.directory?(dir) }
|
||||
@eager_load_paths ||= ["#{root}/app/*"]
|
||||
end
|
||||
|
||||
def load_paths
|
||||
@@ -215,20 +210,13 @@ module Rails
|
||||
# Add the old mock paths only if the directories exists
|
||||
paths.concat(Dir["#{root}/test/mocks/#{Rails.env}"]) if File.exists?("#{root}/test/mocks/#{Rails.env}")
|
||||
|
||||
# Add the app's controller directory
|
||||
paths.concat(Dir["#{root}/app/controllers/"])
|
||||
|
||||
# Followed by the standard includes.
|
||||
paths.concat %w(
|
||||
app
|
||||
app/metal
|
||||
app/models
|
||||
app/controllers
|
||||
app/helpers
|
||||
app/services
|
||||
app/*
|
||||
lib
|
||||
vendor
|
||||
).map { |dir| "#{root}/#{dir}" }.select { |dir| File.directory?(dir) }
|
||||
).map { |dir| "#{root}/#{dir}" }
|
||||
|
||||
paths.concat builtin_directories
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user