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
This commit is contained in:
David Heinemeier Hansson 2007-02-23 00:32:27 +00:00
parent b50a05cac3
commit c6d6082562
5 changed files with 38 additions and 19 deletions

@ -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]

@ -39,8 +39,26 @@ 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
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
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory is automatically loaded
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

@ -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