我正在尝试为Rails 3上的Redmine 2.5.0编写验证器插件。该插件应该检查Issue
的某些值,并在不满足条件的情况下禁止更新。我已经编写了插件代码但不知怎的,我无法让Redmine接受我所做的更改。
我有以下插件项目:
product_release_control |_ config |_ lib | |_ patches | |_ issues_patch.rb |_ init.rb
在我的isssues_patch.rb
我有以下代码:
module ProductReleaseControl
module IssuesPatch
def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
validate :check_related_tasks
end
end
module InstanceMethods
def check_related_tasks
Rails.logger.info "**** INSIDE PRODUCT RELEASE PATCH METHOD"
#code here
end
end
end
end
ActionDispatch::Callbacks.to_prepare do
Issue.send(:include, ProductReleaseControl::IssuesPatch)
end
和init.rb
如下:
#encoding: utf-8
require 'patches/issues_patch'
Redmine::Plugin.register :product_release_control do
name 'Product Release Control plugin'
author 'Author name'
description '...'
version '0.0.1'
end
问题是我执行rake redmine:plugins:migrate
并重新加载apache后,我看不到任何更改。当我运行Issue.included_modules
时,我在列表中看不到我的模块。
我还尝试将ActionDispatch部分移动到init.rb,但这给了我Uninitilized constant ProductReleaseControl
。那么如何在Redmine中包含我的补丁?