Rails 3.0: ActionController :: Base render ()

Can someone explain where the rendering () comes from? ActionController :: Base?

I managed to trace it only so far:

ActionController :: Base includes the ActionController :: Rendering module, where the render () method is defined. However, this definition requires render () of the superclass. The superclass is ActionController :: Metal. What the turn inherits from AbstractController :: Base. None of these () are defined or included.

Now, apparently, this comes from AbstractController :: Rendering, but I'm really missing how it turns on.

+3
source share
2 answers

render, , ActionController::Base.

def render(action = nil, options = {}, &blk)
  options = _normalize_options(action, options, &blk)
  super(options)
end

super, render, ActionController::Rendering.

def render(options)
  super
  self.content_type ||= options[:_template].mime_type.to_s
  response_body
end

ActionController::Rendering , ActionController:: Base base.rb .

include ActionController::Redirecting
include ActionController::Rendering # <--
include ActionController::Renderers::All

ActionController::Rendering AbstractController::Rendering, ActionController::Rendering.

module ActionController
  module Rendering
    extend ActiveSupport::Concern

    included do
      include AbstractController::Rendering
      include AbstractController::LocalizedCache
    end

AbstractController::Rendering render, , .

# Mostly abstracts the fact that calling render twice is a DoubleRenderError.
# Delegates render_to_body and sticks the result in self.response_body.
def render(*args)
  if response_body
    raise AbstractController::DoubleRenderError, "Can only render or redirect once per action"
  end

  self.response_body = render_to_body(*args)
end

AbstractController::Base#render 
--> super() 
--> ActionController::Rendering#render
--> super()
--> AbstractController::Rendering#render
--> render_to_body
+8

render AbstractController::Rendering. render_to_body, , , . , ?

0

Source: https://habr.com/ru/post/1729092/


All Articles