use_renderers

- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (38)
- 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 (-3)
- 7.1.3.4 (0)
- What's this?
use_renderers(*args)
public
Adds, by name, a renderer or renderers to the _renderers available to call within controller actions.
It is useful when rendering from an ActionController::Metal controller or otherwise to add an available renderer proc to a specific controller.
Both ActionController::Base and ActionController::API include ActionController::Renderers::All, making all renderers available in the controller. See Renderers::RENDERERS and Renderers.add.
Since ActionController::Metal controllers cannot render, the controller must include AbstractController::Rendering, ActionController::Rendering, and ActionController::Renderers, and have at lest one renderer.
Rather than including ActionController::Renderers::All and including all renderers, you may specify which renderers to include by passing the renderer name or names to use_renderers. For example, a controller that includes only the :json renderer (_render_with_renderer_json) might look like:
class MetalRenderingController < ActionController::Metal include AbstractController::Rendering include ActionController::Rendering include ActionController::Renderers use_renderers :json def show render json: record end end
You must specify a use_renderer, else the controller.renderer and controller._renderers will be nil, and the action will fail.