2009-04-27 21:21:26 -04:00
|
|
|
module ActionController
|
|
|
|
module Rails2Compatibility
|
2009-05-28 12:35:36 -04:00
|
|
|
extend ActiveSupport::Concern
|
2009-05-21 05:50:34 -04:00
|
|
|
|
|
|
|
class ::ActionController::ActionControllerError < StandardError #:nodoc:
|
|
|
|
end
|
|
|
|
|
2009-05-01 20:27:44 -04:00
|
|
|
# Temporary hax
|
2009-05-11 20:07:05 -04:00
|
|
|
included do
|
2009-05-11 15:45:26 -04:00
|
|
|
::ActionController::UnknownAction = ::AbstractController::ActionNotFound
|
|
|
|
::ActionController::DoubleRenderError = ::AbstractController::DoubleRenderError
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-01 20:27:44 -04:00
|
|
|
cattr_accessor :session_options
|
2009-05-12 19:21:34 -04:00
|
|
|
self.session_options = {}
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-01 20:27:44 -04:00
|
|
|
cattr_accessor :allow_concurrency
|
2009-05-12 19:21:34 -04:00
|
|
|
self.allow_concurrency = false
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-01 20:27:44 -04:00
|
|
|
cattr_accessor :param_parsers
|
2009-05-12 19:21:34 -04:00
|
|
|
self.param_parsers = { Mime::MULTIPART_FORM => :multipart_form,
|
|
|
|
Mime::URL_ENCODED_FORM => :url_encoded_form,
|
|
|
|
Mime::XML => :xml_simple,
|
|
|
|
Mime::JSON => :json }
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-01 20:27:44 -04:00
|
|
|
cattr_accessor :relative_url_root
|
2009-05-12 19:21:34 -04:00
|
|
|
self.relative_url_root = ENV['RAILS_RELATIVE_URL_ROOT']
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-01 20:27:44 -04:00
|
|
|
cattr_accessor :default_charset
|
2009-05-12 19:21:34 -04:00
|
|
|
self.default_charset = "utf-8"
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-12 19:21:34 -04:00
|
|
|
# cattr_reader :protected_instance_variables
|
|
|
|
cattr_accessor :protected_instance_variables
|
|
|
|
self.protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller
|
2009-05-11 17:48:58 -04:00
|
|
|
@action_name @before_filter_chain_aborted @action_cache_path @_headers @_params
|
2009-05-12 19:21:34 -04:00
|
|
|
@_flash @_response)
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-12 19:21:34 -04:00
|
|
|
# Indicates whether or not optimise the generated named
|
|
|
|
# route helper methods
|
|
|
|
cattr_accessor :optimise_named_routes
|
|
|
|
self.optimise_named_routes = true
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-12 19:21:34 -04:00
|
|
|
cattr_accessor :resources_path_names
|
|
|
|
self.resources_path_names = { :new => 'new', :edit => 'edit' }
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-12 19:21:34 -04:00
|
|
|
# Controls the resource action separator
|
|
|
|
cattr_accessor :resource_action_separator
|
|
|
|
self.resource_action_separator = "/"
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-14 20:25:10 -04:00
|
|
|
cattr_accessor :use_accept_header
|
|
|
|
self.use_accept_header = true
|
2009-05-15 20:49:11 -04:00
|
|
|
|
|
|
|
cattr_accessor :page_cache_directory
|
|
|
|
self.page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : ""
|
|
|
|
|
|
|
|
cattr_reader :cache_store
|
|
|
|
|
|
|
|
cattr_accessor :consider_all_requests_local
|
|
|
|
self.consider_all_requests_local = true
|
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
|
2009-05-26 18:03:09 -04:00
|
|
|
|
|
|
|
cattr_accessor :ip_spoofing_check
|
|
|
|
self.ip_spoofing_check = true
|
2009-05-11 17:48:58 -04:00
|
|
|
end
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-19 21:08:04 -04:00
|
|
|
# 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
|
2009-05-26 15:06:48 -04:00
|
|
|
@template ||= _action_view
|
|
|
|
end
|
|
|
|
|
|
|
|
def process_action(*)
|
|
|
|
template
|
|
|
|
super
|
2009-05-20 18:33:08 -04:00
|
|
|
end
|
|
|
|
|
2009-05-11 17:48:58 -04:00
|
|
|
module ClassMethods
|
2009-05-28 10:49:02 -04:00
|
|
|
def consider_all_requests_local
|
|
|
|
end
|
|
|
|
|
2009-05-11 20:07:05 -04:00
|
|
|
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
|
2009-05-01 20:27:44 -04:00
|
|
|
end
|
2009-05-28 10:49:02 -04:00
|
|
|
|
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
|
2009-05-28 10:49:02 -04:00
|
|
|
|
2009-05-11 15:04:43 -04:00
|
|
|
options[:text] = nil if options[:nothing] == true
|
|
|
|
|
2009-05-21 23:22:18 -04:00
|
|
|
body = super
|
|
|
|
body = [' '] if body.blank?
|
|
|
|
body
|
2009-04-27 21:21:26 -04:00
|
|
|
end
|
2009-05-15 18:57:12 -04:00
|
|
|
|
|
|
|
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")
|
2009-05-28 10:49:02 -04:00
|
|
|
end
|
|
|
|
|
2009-06-09 19:46:42 -04:00
|
|
|
def _find_by_parts(name, details)
|
|
|
|
details[:prefix] = nil if name =~ /\blayouts/
|
|
|
|
super
|
2009-05-11 15:45:26 -04:00
|
|
|
end
|
2009-05-20 20:55:25 -04:00
|
|
|
|
|
|
|
def performed?
|
|
|
|
response_body
|
|
|
|
end
|
2009-05-26 15:14:50 -04:00
|
|
|
|
|
|
|
# ==== 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
|
|
|
|
_action_view.view_paths
|
|
|
|
end
|
2009-04-27 21:21:26 -04:00
|
|
|
end
|
2009-05-21 23:22:18 -04:00
|
|
|
end
|