diff options
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application.rb | 9 | ||||
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 3 | ||||
-rw-r--r-- | railties/lib/rails/application/finisher.rb | 4 | ||||
-rw-r--r-- | railties/lib/rails/engine.rb | 6 |
4 files changed, 13 insertions, 9 deletions
diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index f1d546fc59..2648476d6d 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -46,10 +46,11 @@ module Rails # 5) Load config/environments/ENV.rb # 6) Run config.before_initialize callbacks # 7) Run Railtie#initializer defined by railties, engines and application. - # One by one, each engine sets up its load paths, routes and runs its initializer files. - # 8) Build the middleware stack and run to_prepare callbacks - # 9) Run config.before_eager_load and eager_load if cache classes is true - # 10) Run config.after_initialize callbacks + # One by one, each engine sets up its load paths, routes, locales and so on. + # 8) Runs all registered config/initializers/*, executing the engines one first + # 9) Build the middleware stack and run to_prepare callbacks + # 10) Run config.before_eager_load and eager_load if cache classes is true + # 11) Run config.after_initialize callbacks # class Application < Engine autoload :Bootstrap, 'rails/application/bootstrap' diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index e95b0f5495..9e1a5be358 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -11,7 +11,7 @@ module Rails :force_ssl, :helpers_paths, :logger, :log_tags, :preload_frameworks, :reload_plugins, :secret_token, :serve_static_assets, :ssl_options, :static_cache_control, :session_options, - :time_zone, :whiny_nils, :railties_order + :time_zone, :whiny_nils, :railties_order, :all_initializers attr_writer :log_level attr_reader :encoding @@ -36,6 +36,7 @@ module Rails @generators = app_generators @cache_store = [ :file_store, "#{root}/tmp/cache/" ] @railties_order = [:all] + @all_initializers = [] @assets = ActiveSupport::OrderedOptions.new @assets.enabled = false diff --git a/railties/lib/rails/application/finisher.rb b/railties/lib/rails/application/finisher.rb index df2853498a..9c25e05ee5 100644 --- a/railties/lib/rails/application/finisher.rb +++ b/railties/lib/rails/application/finisher.rb @@ -4,6 +4,10 @@ module Rails include Initializable $rails_rake_task = nil + initializer :load_config_initializers do + config.all_initializers.each { |init| load(init) } + end + initializer :add_generator_templates do config.generators.templates.unshift(*paths["lib/templates"].existent) end diff --git a/railties/lib/rails/engine.rb b/railties/lib/rails/engine.rb index 5c1af99fe2..8ebe1f48a5 100644 --- a/railties/lib/rails/engine.rb +++ b/railties/lib/rails/engine.rb @@ -583,10 +583,8 @@ module Rails end end - initializer :load_config_initializers do - config.paths["config/initializers"].existent.sort.each do |initializer| - load(initializer) - end + initializer :append_config_initializers do |app| + app.config.all_initializers.concat config.paths["config/initializers"].existent.sort end initializer :engines_blank_point do |