Module: ActionController::Components
- Defined in:
- lib/action_controller/components.rb
Overview
Components allows you to call other actions for their rendered response while execution another action. You can either delegate the entire response rendering or you can mix a partial response in with your other content.
class WeblogController < ActionController::Base
# Performs a method and then lets hello_world output its render
def delegate_action
do_other_stuff_before_hello_world
render_component :controller => "greeter", :action => "hello_world", :params => { "person" => "david" }
end
end
class GreeterController < ActionController::Base
def hello_world
render_text "#{@params['person']} says, Hello World!"
end
end
The same can be done in a view to do a partial rendering:
Let's see a greeting:
<%= render_component :controller => "greeter", :action => "hello_world" %>
Class Method Summary collapse
-
.append_features(base) ⇒ Object
:nodoc:.
Class Method Details
.append_features(base) ⇒ Object
:nodoc:
24 25 26 27 28 29 30 31 |
# File 'lib/action_controller/components.rb', line 24 def self.append_features(base) #:nodoc: super base.helper do def render_component() @controller.send(:render_component_as_string, ) end end end |