Permalink
Browse files

Provide a unique point for running initializers.

  • Loading branch information...
1 parent 27f0add commit c2e3ce8d1e1174e66536d59d8d97eb2cc8ce6f25 @josevalim josevalim committed Dec 12, 2011
@@ -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'
@@ -11,7 +11,7 @@ class Configuration < ::Rails::Engine::Configuration
: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 @@ def initialize(*)
@generators = app_generators
@cache_store = [ :file_store, "#{root}/tmp/cache/" ]
@railties_order = [:all]
+ @all_initializers = []
@assets = ActiveSupport::OrderedOptions.new
@assets.enabled = false
@@ -4,6 +4,10 @@ module Finisher
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
@@ -583,10 +583,8 @@ def load_seed
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

0 comments on commit c2e3ce8

Please sign in to comment.