| Module | ActionController::Components::InstanceMethods |
| In: |
actionpack/lib/action_controller/components.rb
|
Renders the component specified as the response for the current method
# File actionpack/lib/action_controller/components.rb, line 79 def render_component(options) #:doc: component_logging(options) do render_for_text(component_response(options, true).body, response.headers["Status"]) end end
Returns the component response as a string
# File actionpack/lib/action_controller/components.rb, line 86 def render_component_as_string(options) #:doc: component_logging(options) do response = component_response(options, false) if redirected = response.redirected_to render_component_as_string(redirected) else response.body end end end
determine the controller class for the component request
# File actionpack/lib/action_controller/components.rb, line 120 def component_class(options) if controller = options[:controller] controller.is_a?(Class) ? controller : "#{controller.camelize}Controller".constantize else self.class end end
# File actionpack/lib/action_controller/components.rb, line 145 def component_logging(options) if logger logger.info "Start rendering component (#{options.inspect}): " result = yield logger.info "\n\nEnd of component rendering" result else yield end end
# File actionpack/lib/action_controller/components.rb, line 111 def component_response(options, reuse_response) klass = component_class(options) request = request_for_component(klass.controller_name, options) new_response = reuse_response ? response : response.dup klass.process_with_components(request, new_response, self) end
# File actionpack/lib/action_controller/components.rb, line 160 def process_cleanup_with_components process_cleanup_without_components unless component_request? end
Create a new request object based on the current request. The new request inherits the session from the current request, bypassing any session options set for the component controller’s class
# File actionpack/lib/action_controller/components.rb, line 131 def request_for_component(controller_name, options) new_request = request.dup new_request.session = request.session new_request.instance_variable_set( :@parameters, (options[:params] || {}).with_indifferent_access.update( "controller" => controller_name, "action" => options[:action], "id" => options[:id] ) ) new_request end