我正在创建一个带有菜单选项卡的Redmine插件。按照指南
http://www.redmine.org/projects/redmine/wiki/Plugin_Tutorial
我可以在文件init.rb中添加一个菜单选项卡,如下所示:
permission :polls, { :polls => [:index, :vote] }, :public => true
menu :project_menu, :polls, { :controller => 'polls', :action => 'index' }, :caption => 'Polls', :after => :activity, :param => :project_id
PollsController的菜单选项卡正常。
但是我在同一个插件中创建了一个新的控制器(例如,ArticlesController)。民意调查中有一个链接#index转到文章#new。但文章#new没有出现在菜单中,它显示为我没有创建菜单。 如何使用ArticlesController的“民意调查”菜单选项卡。
我试过了:
class ArticlesController < ApplicationController
menu_item :pivot_table
....
end
和
permission :polls, { :polls => [:index, :vote] }, :public => true
permission :polls, { :articles => [:index, :vote] }, :public => true
menu :project_menu, :polls, { :controller => 'polls', :action => 'index' }, :caption => 'Polls', :after => :activity, :param => :project_id
但没有运气。
这是我的routes.rb:
RedmineApp::Application.routes.draw do
resources :projects do
resources :polls, :only => [:index]
resources :articles, :only => [:new, :create]
end
resources :articles, :except => [:show]
end
请帮助我。我的redmine版本是2.3.2。谢谢。
答案 0 :(得分:0)
不确定这是否是您要求的,但要在项目菜单中获得2个标签,您可以尝试:
Redmine::MenuManager.map :project_menu do |menu|
menu.push :polls, { :controller => 'polls', :action => 'index' }, :param => :project_id, :caption => 'Polls', :after => :activity
menu.push :articles, { :controller => 'articles', :action => 'new' }, :param => :project_id, :caption => 'Articles', :after => :activity
end
答案 1 :(得分:0)
我发现了我的问题。这是init.rb中的权限
我的错误配置:
permission :polls, { :polls => [:index, :vote] }, :public => true
permission :polls, { :articles => [:index, :vote] }, :public => true
menu :project_menu, :polls, { :controller => 'polls', :action => 'index' }, :caption => 'Polls', :after => :activity, :param => :project_id
名称“permission:polls”是重复的。我错了。我认为“:民意调查”就是名字。但这是许可的名称。我改成另一个名字,没关系。
permission :polls, { :polls => [:index, :vote] }, :public => true
permission :articles_permission, { :articles => [:index, :vote] }, :public => true
menu :project_menu, :polls, { :controller => 'polls', :action => 'index' }, :caption => 'Polls', :after => :activity, :param => :project_id