module TabsOnRails::ActionController::ClassMethods

Public Instance Methods

set_tab(*args) click to toggle source

Sets the value for current tab to given name.

set_tab :foo

If you need to manage multiple tabs, then you can pass an optional namespace.

set_tab :foo, :namespace

The set_tab method understands all options you are used to pass to a Rails controller filter. In fact, behind the scenes this method uses a before_filter to store the tab in the @tab_stack variable. For example, you can set the tab only for a restricted group of actions in the same controller using the :only and :except options.

Examples

set_tab :foo
set_tab :foo, :except => :new
set_tab :foo, :only => [ :index, :show ]

set_tab :foo, :namespace
set_tab :foo, :namespace, :only => [ :index, :show ]
# File lib/tabs_on_rails/action_controller.rb, line 102
def set_tab(*args)
  options = args.extract_options!
  name, namespace = args

  before_action(options) do |controller|
    controller.send(:set_tab, name, namespace)
  end
end