1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_controller/metal/compatibility.rb

176 lines
5.8 KiB
Ruby
Raw Normal View History

2009-04-27 21:21:26 -04:00
module ActionController
module Compatibility
extend ActiveSupport::Concern
include AbstractController::Compatibility
class ::ActionController::ActionControllerError < StandardError #:nodoc:
end
module ClassMethods
end
# Temporary hax
included do
::ActionController::UnknownAction = ::AbstractController::ActionNotFound
::ActionController::DoubleRenderError = ::AbstractController::DoubleRenderError
# 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']
2009-08-10 11:40:41 -04:00
class << self
delegate :default_charset=, :to => "ActionDispatch::Response"
end
# cattr_reader :protected_instance_variables
cattr_accessor :protected_instance_variables
2009-10-29 00:37:29 -04:00
self.protected_instance_variables = %w(@assigns @performed_redirect @performed_render
@variables_added @request_origin @url
@parent_controller @action_name
@before_filter_chain_aborted @_headers @_params
2010-01-15 15:44:27 -05:00
@_response)
# Controls the resource action separator
cattr_accessor :resource_action_separator
self.resource_action_separator = "/"
cattr_accessor :use_accept_header
self.use_accept_header = true
2009-05-15 20:49:11 -04:00
self.page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
2009-05-22 20:29:44 -04:00
# Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets,
# and images to a dedicated asset server away from the main web server. Example:
# ActionController::Base.asset_host = "http://assets.example.com"
cattr_accessor :asset_host
cattr_accessor :ip_spoofing_check
self.ip_spoofing_check = true
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
2009-05-20 18:33:08 -04:00
# TODO: Remove this after we flip
def template
@template ||= view_context
end
def process_action(*)
template
super
2009-05-20 18:33:08 -04:00
end
module ClassMethods
def consider_all_requests_local
ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local is deprecated, " <<
"use Rails.application.config.consider_all_requests_local instead"
Rails.application.config.consider_all_requests_local
end
def consider_all_requests_local=(value)
ActiveSupport::Deprecation.warn "ActionController::Base.consider_all_requests_local= is no longer effective. " <<
"Please configure it on your application with config.consider_all_requests_local="
Rails.application.config.consider_all_requests_local = value
end
def allow_concurrency
ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency is deprecated, " <<
"use Rails.application.config.allow_concurrency instead"
Rails.application.config.allow_concurrency
end
def allow_concurrency=(value)
ActiveSupport::Deprecation.warn "ActionController::Base.allow_concurrency= is no longer effective. " <<
"Please configure it on your application with config.allow_concurrency="
Rails.application.config.allow_concurrency = value
end
def rescue_action(env)
raise env["action_dispatch.rescue.exception"]
end
2009-05-15 20:49:11 -04:00
# Defines the storage option for cached fragments
def cache_store=(store_option)
@@cache_store = ActiveSupport::Cache.lookup_store(store_option)
end
end
delegate :consider_all_requests_local, :consider_all_requests_local=,
:allow_concurrency, :allow_concurrency=, :to => :"self.class"
2009-04-27 21:21:26 -04:00
def render_to_body(options)
if options.is_a?(Hash) && options.key?(:template)
options[:template].sub!(/^\//, '')
end
options[:text] = nil if options.delete(:nothing) == true
options[:text] = " " if options.key?(:text) && options[:text].nil?
2009-05-11 15:04:43 -04:00
super || " "
2009-04-27 21:21:26 -04:00
end
def _handle_method_missing
method_missing(@_action_name.to_sym)
end
def method_for_action(action_name)
super || (respond_to?(:method_missing) && "_handle_method_missing")
end
def performed?
response_body
end
# ==== Request only view path switching ====
def append_view_path(path)
view_paths.push(*path)
end
def prepend_view_path(path)
view_paths.unshift(*path)
end
def view_paths
view_context.view_paths
end
2009-04-27 21:21:26 -04:00
end
end