- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0
- 3.0.9
- 3.1.0
- 3.2.1
- 3.2.8
- 3.2.13
- 4.0.2
- 4.1.8
- 4.2.1
- 4.2.7
- 4.2.9
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (-38)
- 7.1.3.4 (0)
- What's this?
ActionController::Renderer allows 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:
-
by changing renderer defaults, like
ApplicationController.renderer.defaults # => hash with default Rack environment
-
by initializing an instance of renderer by passing it a custom environment.
ApplicationController.renderer.new(method: 'post', https: true)
Constants
RACK_VALUE_TRANSLATION = { https: ->(v) { v ? 'on' : 'off' }, method: ->(v) { v.upcase }, }
IDENTITY = ->(_) { _ }
RACK_KEY_TRANSLATION = { http_host: 'HTTP_HOST', https: 'HTTPS', method: 'REQUEST_METHOD', script_name: 'SCRIPT_NAME', input: 'rack.input' }
DEFAULTS = { http_host: 'example.org', https: false, method: 'get', script_name: '', input: '' }.freeze
Attributes
[R] | controller | |
[R] | defaults |