Module | ActionController::Components |
In: |
lib/action_controller/components.rb
|
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" %>