Flowdock
v1.0.0 - Show latest stable - 0 notes

Components allows you to call other actions for their rendered response while executing 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" %>
Show files where this module is defined (1 file)
Register or log in to add new notes.