class

ActionController::Renderer

v7.0.0 - Show latest stable - Superclass: Object

ActionController::Renderer allows you to render arbitrary templates without requirement of being in controller actions.

You get a concrete renderer class by invoking ActionController::Base#renderer. For example:

ApplicationController.renderer

It allows you to call method #render directly.

ApplicationController.renderer.render template: '...'

You can use this shortcut in a controller, instead of the previous example:

ApplicationController.render template: '...'

#render allows you to use the same options that you can use when rendering in a controller. For example:

FooController.render :action, locals: { ... }, assigns: { ... }

The template will be rendered in a Rack environment which is accessible through ActionController::Renderer#env. You can set it up in two ways:

Constants

DEFAULTS = {\nhttp_host: "example.org",\nhttps: false,\nmethod: "get",\nscript_name: "",\ninput: ""\n}.freeze

RACK_KEY_TRANSLATION = {\nhttp_host: "HTTP_HOST",\nhttps: "HTTPS",\nmethod: "REQUEST_METHOD",\nscript_name: "SCRIPT_NAME",\ninput: "rack.input"\n}

Attributes

[R]controller
[R]defaults

Files

  • actionpack/lib/action_controller/renderer.rb