From f73e9d2df8e40cdbf145995452f6e7c88b98c232 Mon Sep 17 00:00:00 2001 From: wycats Date: Mon, 2 Aug 2010 23:39:17 -0700 Subject: [PATCH] Properly deprecate `config.load_paths` and `config.gem` --- railties/lib/rails/engine/configuration.rb | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index 521ed95447..26b1a68b66 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -48,6 +48,33 @@ module Rails def autoload_paths @autoload_paths ||= paths.autoload_paths end + + def load_paths + ActiveSupport::Deprecation.warn "config.load_paths is deprecated. Please use config.autoload_paths instead." + autoload_paths + end + + def load_paths=(paths) + ActiveSupport::Deprecation.warn "config.load_paths= is deprecated. Please use config.autoload_paths instead." + self.autoload_paths = paths + end + + # Rails 3, by default, uses bundler, which shims the Kernel#gem method so that it should + # behave correctly for this deprecation. + def gem(name, options = {}) + super name, options[:version] || ">= 0" + require options[:lib] || name + rescue Gem::LoadError + msg = "config.gem is deprecated, and you tried to activate the '#{name}' gem using it.\n" + + if File.exist?("#{Rails.root}/Gemfile") + msg << "Please add '#{name}' to your Gemfile." + else + msg << "Please update your application to use bundler." + end + ActiveSupport::Deprecation.warn(msg, caller) + exit + end end end end