Permalink
Browse files

Added config/initializers where all ruby files within it are automati…

…cally 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
  • Loading branch information...
1 parent b50a05c commit c6d6082562b91831cefc0aa53b74c3f4c2805e64 @dhh dhh committed Feb 23, 2007
View
@@ -1,5 +1,7 @@
*SVN*
+* 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]
+
* For new apps, generate a random secret for the cookie-based session store. [Jeremy Kemper]
* Stop swallowing errors during rake test [Koz]
View
@@ -38,9 +38,27 @@ Rake::TestTask.new("regular_test") do |t|
end
-BASE_DIRS = %w(
- app config/environments components db doc log lib lib/tasks public script script/performance script/process test vendor vendor/plugins
- tmp/sessions tmp/cache tmp/sockets tmp/pids
+BASE_DIRS = %w(
+ app
+ config/environments
+ config/initializers
+ components
+ db
+ doc
+ log
+ lib
+ lib/tasks
+ public
+ script
+ script/performance
+ script/process
+ test
+ vendor
+ vendor/plugins
+ tmp/sessions
+ tmp/cache
+ tmp/sockets
+ tmp/pids
)
APP_DIRS = %w( models controllers helpers views views/layouts )
@@ -49,19 +49,7 @@
# config.active_record.default_timezone = :utc
# See Rails::Configuration for more options
-end
-
-# Add new inflection rules using the following format
-# (all these examples are active by default):
-# Inflector.inflections do |inflect|
-# inflect.plural /^(ox)$/i, '\1en'
-# inflect.singular /^(ox)en/i, '\1'
-# inflect.irregular 'person', 'people'
-# inflect.uncountable %w( fish sheep )
-# end
-
-# Add new mime types for use in respond_to blocks:
-# Mime::Type.register "text/richtext", :rtf
-# Mime::Type.register "application/x-mobile", :mobile
-
-# Include your application configuration below
+
+ # Application configuration should go into files in config/initializers
+ # -- all .rb files in that directory is automatically loaded
+end
@@ -70,6 +70,8 @@ def initialize(configuration)
# * #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 @@ def process
# the framework is now fully initialized
after_initialize
+
+ load_application_initializers
end
# Check for valid Ruby version
@@ -334,6 +338,12 @@ def after_initialize
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.
@@ -121,6 +121,7 @@ def mysql_socket_location
app/models
app/views/layouts
config/environments
+ config/initializers
db
doc
lib

0 comments on commit c6d6082

Please sign in to comment.