Module: ActionController::Rendering

Extended by:
ActiveSupport::Concern
Included in:
DataStreaming
Defined in:
lib/action_controller/metal/rendering.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

RENDER_FORMATS_IN_PRIORITY =
[:body, :plain, :html]

Instance Method Summary collapse

Instance Method Details

#process_actionObject

Before processing, set the request formats in current controller formats.



28
29
30
31
# File 'lib/action_controller/metal/rendering.rb', line 28

def process_action(*) #:nodoc:
  self.formats = request.formats.map(&:ref).compact
  super
end

#render(*args) ⇒ Object

Check for double render errors and set the content_type after rendering.



34
35
36
37
# File 'lib/action_controller/metal/rendering.rb', line 34

def render(*args) #:nodoc:
  raise ::AbstractController::DoubleRenderError if response_body
  super
end

#render_to_body(options = {}) ⇒ Object



51
52
53
# File 'lib/action_controller/metal/rendering.rb', line 51

def render_to_body(options = {})
  super || _render_in_priorities(options) || " "
end

#render_to_stringObject

Overwrite render_to_string because body can now be set to a Rack body.



40
41
42
43
44
45
46
47
48
49
# File 'lib/action_controller/metal/rendering.rb', line 40

def render_to_string(*)
  result = super
  if result.respond_to?(:each)
    string = "".dup
    result.each { |r| string << r }
    string
  else
    result
  end
end