我是Redmine开发的初学者。我创建了一个插件并将其添加到项目菜单中。但是当我点击这个标签时,它没有链接到我想要的页面,项目菜单栏消失了。很难控制项目管理的所有活动。我该怎么办?
这是我的init.rb
文件中的代码:
permission :project_plan, { :project_plan => [:index,:show] }, :public => true
menu :project_menu, :redmine_project_plan, { :controller => 'project_plan', :action => 'index' }, :caption => :project_plan_title
答案 0 :(得分:0)
我认为您的问题是您没有将project_id作为参数提供,上面的代码应该更像
permission :project_plan, { :project_plan => [:index,:show] }, :public => true
menu :project_menu, :redmine_project_plan, { :controller => 'project_plan', :action ='index' }, :caption => :project_plan_title, :param => project_id
在控制器上,您需要重新获取此信息:
@project= params[:project_id]
答案 1 :(得分:0)
在经过数小时的研究和调查后,我的Redmine插件也遇到了同样的问题。重要的是使用传递到show方法中的项目id参数更新@project变量。这是我的控制器文件:
class YearlyController < ApplicationController
unloadable
helper :issues
include IssuesHelper
def show
require_login
@project = Project.find(params[:project_id])
end
end
和init.rb文件:
Redmine::Plugin.register :weekly do
name 'Weekly Plan plugin'
description 'Display weekly plan for current and previous week'
version '0.0.2'
menu :project_menu, :yearly, { :controller => 'yearly', :action => 'show' }, :caption => 'Roadmap Year', :after => :overview, :param => :project_id
menu :project_menu, :weekly, { :controller => 'weekly', :action => 'show' }, :caption => 'Weekly Plan', :after => :yearly, :param => :project_id
settings :default => { :weeklabel_name => 'Weekly Label' }, :partial => 'settings/settings'
project_module :weekly do
permission :view_weekly, :weekly => :show
permission :view_yearly, :yearly => :show
end
end