class method
self.new
Ruby on Rails 8.1.2
Since v5.2.8.1Signature
self.new(controller, env, defaults)
Initializes a new Renderer.
Parameters
-
controller- The controller class to instantiate for rendering. -
env- The Rack env to use for mocking a request when rendering. Entries can be typical Rack env keys and values, or they can be any of the following, which will be converted appropriately:-
:http_host- The HTTP host for the incoming request. Converts to Rack’sHTTP_HOST. -
:https- Boolean indicating whether the incoming request uses HTTPS. Converts to Rack’sHTTPS. -
:method- The HTTP method for the incoming request, case-insensitive. Converts to Rack’sREQUEST_METHOD. -
:script_name- The portion of the incoming request’s URL path that corresponds to the application. Converts to Rack’sSCRIPT_NAME. -
:input- The input stream. Converts to Rack’srack.input.
-
-
defaults- Default values for the Rack env. Entries are specified in the same format asenv.envwill be merged on top of these values.defaultswill be retained when calling #new on a renderer instance.
If no http_host is specified, the env HTTP host will be derived from the routes’ default_url_options. In this case, the https boolean and the script_name will also be derived from default_url_options if they were not specified. Additionally, the https boolean will fall back to Rails.application.config.force_ssl if default_url_options does not specify a protocol.
Parameters
-
controllerreq -
envreq -
defaultsreq
Source
# File actionpack/lib/action_controller/renderer.rb, line 110
def initialize(controller, env, defaults)
@controller = controller
@defaults = defaults
if env.blank? && @defaults == DEFAULTS
@env = DEFAULT_ENV
else
@env = normalize_env(@defaults)
@env.merge!(normalize_env(env)) unless env.blank?
end
end
Defined in actionpack/lib/action_controller/renderer.rb line 110
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Renderer