plugin rails/init.rb deprecation message

This commit is contained in:
Jeremy Kemper
2010-02-26 13:29:44 -08:00
parent be0bf10a3c
commit 6324eeefd7
2 changed files with 17 additions and 15 deletions

View File

@@ -95,8 +95,8 @@ module Rails
initializer :add_view_paths do
views = paths.app.views.to_a
ActionController::Base.view_paths.unshift(*views) if defined?(ActionController)
ActionMailer::Base.view_paths.unshift(*views) if defined?(ActionMailer)
ActionController::Base.prepend_view_path(views) if defined?(ActionController)
ActionMailer::Base.prepend_view_path(views) if defined?(ActionMailer)
end
initializer :add_metals do |app|
@@ -132,4 +132,4 @@ module Rails
app.config.reload_engines
end
end
end
end

View File

@@ -26,11 +26,14 @@ module Rails
def load_tasks
super
extra_tasks = Dir["#{root}/{tasks,rails/tasks}/**/*.rake"]
load_deprecated_tasks
end
unless extra_tasks.empty?
ActiveSupport::Deprecation.warn "Rake tasks in #{extra_tasks.to_sentence} are deprecated. Use lib/tasks instead"
extra_tasks.sort.each { |ext| load(ext) }
def load_deprecated_tasks
tasks = Dir["#{root}/{tasks,rails/tasks}/**/*.rake"].sort
if tasks.any?
ActiveSupport::Deprecation.warn "Rake tasks in #{tasks.to_sentence} are deprecated. Use lib/tasks instead"
tasks.each { |ext| load(ext) }
end
end
@@ -44,15 +47,14 @@ module Rails
end
initializer :load_init_rb, :before => :load_application_initializers do |app|
if File.file?(file = File.expand_path("rails/init.rb", root))
ActiveSupport::Deprecation.warn "PLUGIN_PATH/rails/init.rb in plugins is deprecated. " <<
"Use PLUGIN_PATH/init.rb instead"
else
file = File.expand_path("init.rb", root)
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}"
end
config = app.config
eval(File.read(initrb), binding, initrb)
end
config = app.config
eval(File.read(file), binding, file) if file && File.file?(file)
end
initializer :sanity_check_railties_collision do