diff options
author | José Valim <jose.valim@gmail.com> | 2010-03-23 23:50:24 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-03-23 23:50:53 +0100 |
commit | 5c41cb77d9af28fe6495d5c4047483ce3ceadfe6 (patch) | |
tree | cc9ab8088b2d3b05d372db80bb77d79c8f52b32e /railties/lib/rails/plugin.rb | |
parent | cc0e402aa870fa710d6b6189dc090244b4462308 (diff) | |
download | rails-5c41cb77d9af28fe6495d5c4047483ce3ceadfe6.tar.gz rails-5c41cb77d9af28fe6495d5c4047483ce3ceadfe6.tar.bz2 rails-5c41cb77d9af28fe6495d5c4047483ce3ceadfe6.zip |
Ensure lib/rails/initializers/*.rb also works for gems.
Diffstat (limited to 'railties/lib/rails/plugin.rb')
-rw-r--r-- | railties/lib/rails/plugin.rb | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/railties/lib/rails/plugin.rb b/railties/lib/rails/plugin.rb index 5d6144959d..a08c5b9143 100644 --- a/railties/lib/rails/plugin.rb +++ b/railties/lib/rails/plugin.rb @@ -47,20 +47,13 @@ module Rails end initializer :load_init_rb, :before => :load_application_initializers do |app| - initializers = Dir["#{root}/lib/rails/initializers/*.rb"] + lib_initializers = paths.lib.rails.initializers.to_a + files = %w(rails/init.rb init.rb).map { |path| File.expand_path(path, root) } - 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 + if lib_initializers.empty? && 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 end |