想用插件的方法 TimeEntry 这个 model 中增加一个 validate,一直不成功,请哪位有经验的大神解解惑 patch 文件位置#{Rails.root}/plugins/time_entry_limit/lib/time_patch.rb
require 'time_entry'
module TimePatch
def self.include(base)
base.send(:include, InstanceMethods)
base.class_eval do
unloadable
validates :issue_id, presence: true
end
end
module InstanceMethods
end
end
TimeEntry.send(:include, TimePatch)
plugin init 文件地址#{Rails.root}/plugins/time_entry_limit/init.rb
require 'redmine'
ActionDispatch::Callbacks.to_prepare do
puts 'require ok====================' if require_dependency 'time_patch'
end
Redmine::Plugin.register :time_entry_limit do
name 'Time Entry Limit plugin'
author 'Author name'
description 'This is a plugin for Redmine'
version '0.0.1'
url 'http://example.com/path/to/plugin'
author_url 'http://example.com/about'
settings :default => {'small' => 4}, :partial => 'settings/time_entry_limit_plugin'
end
代码如上
可是每次添加工时也就是往 time_entries 添加纪录时 issue_id 为空还是能添加成功
求助啊,要崩溃了……