동작에서 호출하는 render
메서드는 ActionController::Base
에 정의되어 있습니다.
def render(action = nil, options = {}, &blk)
options = _normalize_options(action, options, &blk)
super(options)
end
이 방법은 ActionController::Rendering
에 정의 된 render
메소드를 호출 super
에 대한 호출을 전달합니다.
def render(options)
super
self.content_type ||= options[:_template].mime_type.to_s
response_body
end
ActionController::Rendering
효과적으로 base.rb
파일의 시작 부분에 ActionController :: 기본 클래스로 혼합 모듈입니다. 당신이 ActionController::Rendering
모듈 정의에서 볼 수 있듯이 회전에서
include ActionController::Redirecting
include ActionController::Rendering # <--
include ActionController::Renderers::All
, ActionController::Rendering
는 AbstractController::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
전체 체인은, 당신이 18 개 질문을 한 단지 그들 중 넷에 대한 답변을 수락 한
AbstractController::Base#render
--> super()
--> ActionController::Rendering#render
--> super()
--> AbstractController::Rendering#render
--> render_to_body
@artemave이다. 답변이 도움이 되었다면 동의하십시오. 감사! –