ruby-on-rails – Redmine的插件仅出现在某些项目菜单中
发布时间:2020-12-17 02:13:44 所属栏目:百科 来源:网络整理
导读:我让我的Redmine(v2.0.3)工作了.它现在显示在每个项目的项目菜单中,但我无法弄清楚如何仅为所选项目激活它.例如.仅适用于将项目自定义字段设置为特定值的项目.我创建了自定义字段并找出了存储数据的位置.但是,如何告诉Redmine何时在项目菜单中显示插件? 我
我让我的Redmine(v2.0.3)工作了.它现在显示在每个项目的项目菜单中,但我无法弄清楚如何仅为所选项目激活它.例如.仅适用于将项目自定义字段设置为特定值的项目.我创建了自定义字段并找出了存储数据的位置.但是,如何告诉Redmine何时在项目菜单中显示插件?
我确实遇到过使用的可能性:如果要指定一个proc但是proc不允许我调用我的一个插件创建模型的方法. ActionView::Template::Error (undefined method 'check_to_display' for Param(....):Class) 我的init.rb说: menu :project_menu,:info,{:controller=>'info',:action=>'index'},:caption=>'Ticker',:after=>:activity,:param=>:project_id,:if=>Proc.new{||Param.check_to_display()} 解决方法
多么尴尬,一个简单的错误.我将方法check_to_display定义如下:
def check_to_display 显然它应该是 def self.check_to_display 对于那些对总代码感兴趣的人: class Param < ActiveRecord::Base unloadable def self.check_to_display(p) cf = CustomField.where("type='ProjectCustomField' and name='THE_FLAG'").first return false if cf.nil? return false if p.nil? cv = CustomValue.where("customized_type='Project' and customized_id=? and custom_field_id=?",p.id,cf.id).first return false if cv.nil? return false if cv.value.nil? cv.value.strip! return cv.value != "" end end 不要忘记,init.rb应该如下所示: menu :project_menu,:if=>Proc.new{|p|Param.check_to_display(p)} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |