Module: TabsOnRails::ControllerMixin::ClassMethods

Defined in:
lib/tabs_on_rails/controller_mixin.rb

Instance Method Summary collapse

Instance Method Details

#current_tab(*args) ⇒ Object

This method is deprecated and exists only for compatibility with version 0.2. Please use set_tab method instead.



66
67
68
69
# File 'lib/tabs_on_rails/controller_mixin.rb', line 66

def current_tab(*args)
  ActiveSupport::Deprecation.warn("Method current_tab is deprecated and will be removed in a future version. Please use set_tab instead.", caller)
  set_tab(*args)
end

#set_tab(*args) ⇒ Object

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 ]


55
56
57
58
59
60
61
62
# File 'lib/tabs_on_rails/controller_mixin.rb', line 55

def set_tab(*args)
  options = args.extract_options!
  name, namespace = args
  
  before_filter(options) do |controller|
    controller.set_tab(name, namespace)
  end
end