Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Context

Context

= Context Plugin

Purpose

It's very simple.

Pass context information to actions, and, in the controller, make it easy to do handle rendering of different content depending on that context.

Usage

In your views: Pass a _context parameter to actions (you can use the context_tag helper in forms)

In your actions: Use in_context. Example:

render :update do |page|
  # Stuff at this point happens regardless of context
  in_context do |context|
    context.nil? do
      # This happens if no context is passed
    end
    context.workflow_one do
      # If params[:_context] is "Workflow One" 
    end
    context.workflow_two do
    # If params[:_context] is "Workflow Two" 
    end
  end
end

== Credits

Author: Bruce Williams (http://codefluency.com)

NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly