Module: Redmine::MenuManager::MenuController::ClassMethods

Defined in:
lib/redmine/menu_manager.rb

Constant Summary collapse

Hash.new {|hash, key| hash[key] = {:default => key, :actions => {}}}

Instance Method Summary collapse

Instance Method Details

Set the menu item name for a controller or specific actions Examples:

* menu_item :tickets # => sets the menu name to :tickets for the whole controller
* menu_item :tickets, :only => :list # => sets the menu name to :tickets for the 'list' action only
* menu_item :tickets, :only => [:list, :show] # => sets the menu name to :tickets for 2 actions only

The default menu item name for a controller is controller_name by default Eg. the default menu item name for ProjectsController is :projects

Since:

  • 0.7.0



44
45
46
47
48
49
50
51
# File 'lib/redmine/menu_manager.rb', line 44

def menu_item(id, options = {})
  if actions = options[:only]
    actions = [] << actions unless actions.is_a?(Array)
    actions.each {|a| menu_items[controller_name.to_sym][:actions][a.to_sym] = id}
  else
    menu_items[controller_name.to_sym][:default] = id
  end
end