diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-03-02 17:20:13 -0800 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-03-03 15:49:52 -0800 |
commit | bcfb77782b9d7f28f0c19005da909162e5e27690 (patch) | |
tree | 136ab5091182ae2b927d31f9a5453b050d647925 /actionpack/lib/action_controller/metal/compatibility.rb | |
parent | 664090348154ccbf1274a13bbc3d3c37ba35bc7d (diff) | |
download | rails-bcfb77782b9d7f28f0c19005da909162e5e27690.tar.gz rails-bcfb77782b9d7f28f0c19005da909162e5e27690.tar.bz2 rails-bcfb77782b9d7f28f0c19005da909162e5e27690.zip |
Work on deprecating ActionController::Base.relative_url_root
Diffstat (limited to 'actionpack/lib/action_controller/metal/compatibility.rb')
-rw-r--r-- | actionpack/lib/action_controller/metal/compatibility.rb | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb index d1c86b296d..93f7b8ca49 100644 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ b/actionpack/lib/action_controller/metal/compatibility.rb @@ -7,13 +7,17 @@ module ActionController class ::ActionController::ActionControllerError < StandardError #:nodoc: end + module ClassMethods + end + # Temporary hax included do ::ActionController::UnknownAction = ::AbstractController::ActionNotFound ::ActionController::DoubleRenderError = ::AbstractController::DoubleRenderError - cattr_accessor :relative_url_root - self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] + # ROUTES TODO: This should be handled by a middleware and route generation + # should be able to handle SCRIPT_NAME + self.config.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT'] class << self delegate :default_charset=, :to => "ActionDispatch::Response" @@ -47,6 +51,39 @@ module ActionController cattr_accessor :trusted_proxies end + def self.deprecated_config_accessor(option, message = nil) + deprecated_config_reader(option, message) + deprecated_config_writer(option, message) + end + + def self.deprecated_config_reader(option, message = nil) + message ||= "Reading #{option} directly from ActionController::Base is deprecated. " \ + "Please read it from config.#{option}" + + ClassMethods.class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{option} + ActiveSupport::Deprecation.warn #{message.inspect} + config.#{option} + end + RUBY + end + + def self.deprecated_config_writer(option, message = nil) + message ||= "Setting #{option} directly on ActionController::Base is deprecated. " \ + "Please set it on config.action_controller.#{option}" + + ClassMethods.class_eval <<-RUBY, __FILE__, __LINE__ + 1 + def #{option}=(val) + ActiveSupport::Deprecation.warn #{message.inspect} + config.#{option} = val + end + RUBY + end + + deprecated_config_writer :session_store + deprecated_config_writer :session_options + deprecated_config_accessor :relative_url_root, "relative_url_root is ineffective. Please stop using it" + # For old tests def initialize_template_class(*) end def assign_shortcuts(*) end |