Skip to content
Browse files

plugin rails/init.rb deprecation message

  • Loading branch information...
1 parent be0bf10 commit 6324eeefd7d1dd7b628afdcf436649062d12bbab @jeremy jeremy committed Feb 26, 2010
Showing with 17 additions and 15 deletions.
  1. +3 −3 railties/lib/rails/engine.rb
  2. +14 −12 railties/lib/rails/plugin.rb
View
6 railties/lib/rails/engine.rb
@@ -95,8 +95,8 @@ def load_tasks
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 @@ def reloadable?(app)
app.config.reload_engines
end
end
-end
+end
View
26 railties/lib/rails/plugin.rb
@@ -26,11 +26,14 @@ def self.all(list, paths)
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 @@ def config
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

0 comments on commit 6324eee

Please sign in to comment.
Something went wrong with that request. Please try again.