ActionController::Base

コントローラーにミックスインされているモジュール

MODULES = [
  AbstractController::Rendering,
  AbstractController::Translation,
  AbstractController::AssetPaths,

  Helpers,
  UrlFor,
  Redirecting,
  ActionView::Layouts,
  Rendering,
  Renderers::All,
  ConditionalGet,
  EtagWithTemplateDigest,
  EtagWithFlash,
  Caching,
  MimeResponds,
  ImplicitRender,
  StrongParameters,
  ParameterEncoding,
  Cookies,
  Flash,
  FormBuilder,
  RequestForgeryProtection,
  ContentSecurityPolicy,
  ForceSSL,
  Streaming,
  DataStreaming,
  HttpAuthentication::Basic::ControllerMethods,
  HttpAuthentication::Digest::ControllerMethods,
  HttpAuthentication::Token::ControllerMethods,
  DefaultHeaders,

  # Before callbacks should also be executed as early as possible, so
  # also include them at the bottom.
  AbstractController::Callbacks,

  # Append rescue at the bottom to wrap as much as possible.
  Rescue,

  # Add instrumentations hooks at the bottom, to ensure they instrument
  # all the methods properly.
  Instrumentation,

  # Params wrapper should come before instrumentation so they are
  # properly showed in logs
  ParamsWrapper
]

参考:

rails/base.rb at v5.2.0 · rails/rails – GitHub

AbstractController::Rendering

参考:

AbstractController::Rendering | Ruby on Rails API [Official]

AbstractController::Translation

参考:

AbstractController::Translation | Ruby on Rails API [Official]

AbstractController::AssetPaths

  • asset_host
  • assets_dir
  • javascripts_dir
  • stylesheets_dir
  • default_asset_host_protocol
  • relative_url_root

参考:

rails/asset_paths.rb at v5.2.0 · rails/rails – GitHub

ActionView::Renderer#render

レンダラーが描画を開始するエントリーポイント

def render(context, options)
  if options.key?(:partial)
    render_partial(context, options)
  else
    render_template(context, options)
  end
end

参考:

render – ActionView::Renderer | Ruby on Rails API [Official]

render – rails/renderer.rb at v5.2.3 · rails/rails – GitHub

render_partial – rails/renderer.rb at v5.2.3 · rails/rails – GitHub

render_template – rails/renderer.rb at v5.2.3 · rails/rails – GitHub

render_to_body

Called by render in AbstractController::Rendering which sets the return value as the response_body.

If no renderer is found, super returns control to ActionView::Rendering.render_to_body, if present.

def render_to_body(options)
  _render_to_body_with_renderer(options) || super
end

def _render_to_body_with_renderer(options)
  _renderers.each do |name|
    if options.key?(name)
      _process_options(options)
      method_name = Renderers._render_with_renderer_method_name(name)
      return send(method_name, options.delete(name), options)
    end
  end
  nil
end
def self._render_with_renderer_method_name(key)
  "_render_with_renderer_#{key}"
end

参考:

render_to_body – ActionController::Renderers | Ruby on Rails API [Official]

render_to_body – rails/renderers.rb at v5.2.0 · rails/rails – GitHub

_render_with_renderer_method_name – rails/renderers.rb at v5.2.0 · rails/rails – GitHub

ActionController::Renderers.add

レンダラーを追加する。

参考:

add – rails/renderers.rb at v5.2.3 · rails/rails – GitHub

js レンダラー

JavaScript コードをレスポンスするレンダラー

add :js do |js, options|
  self.content_type ||= Mime[:js]
  js.respond_to?(:to_js) ? js.to_js(options) : js
end

参考:

add :js – rails/renderers.rb at v5.2.0 · rails/rails – GitHub

ActionController::Renderer

参考:

ActionController::Renderer | Ruby on Rails API [Official]

rails/renderer.rb at v5.2.3 · rails/rails – GitHub

ActionController::Rendering

参考:

ActionController::Rendering | Ruby on Rails API [Official]

rails/rendering.rb at v5.2.3 · rails/rails – GitHub

ActionController::ConditionalGet

参考:

ActionController::ConditionalGet | Ruby on Rails API [Official]

rails/conditional_get.rb at v5.2.3 · rails/rails – GitHub

etag

参考:

etag – ActionController::ConditionalGet::ClassMethods | Ruby on Rails API [Official]

etag – rails/conditional_get.rb at v5.2.3 · rails/rails – GitHub

EtagWithTemplateDigest

参考:

ActionController::EtagWithTemplateDigest | Ruby on Rails API [Official]

rails/etag_with_template_digest.rb at v5.2.3 · rails/rails – GitHub

ActiveSupport::Configurable

参考:

ActiveSupport::Configurable | Ruby on Rails API [Official]

rails/configurable.rb at v5.2.3 · rails/rails – GitHub

config_accessor – rails/configurable.rb at v5.2.3 · rails/rails – GitHub

記事をシェアする:
タグ:

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

Protected by reCAPTCHA