1
module ActionController
3
extend ActiveSupport::Concern
5
include AbstractController::Rendering
7
# Before processing, set the request formats in current controller formats.
8
def process_action(*) #:nodoc:
9
self.formats = request.formats.map { |x| x.ref }
13
# Check for double render errors and set the content_type after rendering.
14
def render(*args) #:nodoc:
15
raise ::AbstractController::DoubleRenderError if response_body
17
self.content_type ||= Mime[lookup_context.rendered_format].to_s
21
# Overwrite render_to_string because body can now be set to a rack body.
22
def render_to_string(*)
23
if self.response_body = super
25
response_body.each { |r| string << r }
29
self.response_body = nil
34
# Normalize arguments by catching blocks and setting them on :update.
35
def _normalize_args(action=nil, options={}, &blk) #:nodoc:
37
options[:update] = blk if block_given?
41
# Normalize both text and status options.
42
def _normalize_options(options) #:nodoc:
43
if options.key?(:text) && options[:text].respond_to?(:to_text)
44
options[:text] = options[:text].to_text
48
options[:status] = Rack::Utils.status_code(options[:status])
54
# Process controller specific options, as status, content-type and location.
55
def _process_options(options) #:nodoc:
56
status, content_type, location = options.values_at(:status, :content_type, :location)
58
self.status = status if status
59
self.content_type = content_type if content_type
60
self.headers["Location"] = url_for(location) if location