diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2007-02-23 00:32:27 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2007-02-23 00:32:27 +0000 |
commit | c6d6082562b91831cefc0aa53b74c3f4c2805e64 (patch) | |
tree | f90d93490cd42e2e0e9ad312c78780f2da019e7a /railties/lib | |
parent | b50a05cac32f7e1f70ea622e2c82972c87391dfa (diff) | |
download | rails-c6d6082562b91831cefc0aa53b74c3f4c2805e64.tar.gz rails-c6d6082562b91831cefc0aa53b74c3f4c2805e64.tar.bz2 rails-c6d6082562b91831cefc0aa53b74c3f4c2805e64.zip |
Added config/initializers where all ruby files within it are automatically loaded after the Rails configuration is done, so you don't have to litter the environment.rb file with a ton of mixed stuff [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6212 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/initializer.rb | 10 | ||||
-rw-r--r-- | railties/lib/rails_generator/generators/applications/app/app_generator.rb | 1 |
2 files changed, 11 insertions, 0 deletions
diff --git a/railties/lib/initializer.rb b/railties/lib/initializer.rb index a3ab73fd51..b535c8624b 100644 --- a/railties/lib/initializer.rb +++ b/railties/lib/initializer.rb @@ -70,6 +70,8 @@ module Rails # * #load_plugins # * #load_observers # * #initialize_routing + # * #after_initialize + # * #load_application_initializers # # (Note that #load_environment is invoked twice, once at the start and # once at the end, to support the legacy configuration style where the @@ -112,6 +114,8 @@ module Rails # the framework is now fully initialized after_initialize + + load_application_initializers end # Check for valid Ruby version @@ -334,6 +338,12 @@ module Rails configuration.after_initialize_block.call if configuration.after_initialize_block end + def load_application_initializers + Dir["#{RAILS_ROOT}/config/initializers/**/*.rb"].each do |initializer| + load(initializer) + end + end + protected # Return a list of plugin paths within base_path. A plugin path is # a directory that contains either a lib directory or an init.rb file. diff --git a/railties/lib/rails_generator/generators/applications/app/app_generator.rb b/railties/lib/rails_generator/generators/applications/app/app_generator.rb index 4c8ffc7502..01fff050ed 100644 --- a/railties/lib/rails_generator/generators/applications/app/app_generator.rb +++ b/railties/lib/rails_generator/generators/applications/app/app_generator.rb @@ -121,6 +121,7 @@ class AppGenerator < Rails::Generator::Base app/models app/views/layouts config/environments + config/initializers db doc lib |