diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-03-23 15:36:32 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-03-23 15:36:32 -0500 |
commit | e47a1d7865f40ae70a4c38e7ea792843641f3bcb (patch) | |
tree | fb5caf1e0d4281b60b9effe1ab393cd9629298b6 /railties/lib/rails | |
parent | b9f551ac156effdc33416bcf479a8149e2419aab (diff) | |
download | rails-e47a1d7865f40ae70a4c38e7ea792843641f3bcb.tar.gz rails-e47a1d7865f40ae70a4c38e7ea792843641f3bcb.tar.bz2 rails-e47a1d7865f40ae70a4c38e7ea792843641f3bcb.zip |
Load plugin initializers from lib/rails/initializers/*.rb
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/plugin.rb | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 98f329cc17..5d6144959d 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -47,13 +47,20 @@ module Rails end initializer :load_init_rb, :before => :load_application_initializers do |app| - files = %w(rails/init.rb init.rb).map { |path| File.expand_path path, root } - if initrb = files.find { |path| File.file? path } - if initrb == files.first - ActiveSupport::Deprecation.warn "Use toplevel init.rb; rails/init.rb is deprecated: #{initrb}" + initializers = Dir["#{root}/lib/rails/initializers/*.rb"] + + if initializers.any? + initializers.each do |initializer| + config = app.config + eval(File.read(initializer), binding, initializer) + end + else + files = %w(rails/init.rb init.rb).map { |path| File.expand_path path, root } + if initrb = files.find { |path| File.file? path } + ActiveSupport::Deprecation.warn "init.rb is deprecated: #{initrb}. Use lib/rails/initializers/#{name}.rb" + config = app.config + eval(File.read(initrb), binding, initrb) end - config = app.config - eval(File.read(initrb), binding, initrb) end end |