Ruby 当问题状态更改为特定状态时,如何设置在redmine中自动添加注释

Ruby 当问题状态更改为特定状态时,如何设置在redmine中自动添加注释,ruby,hook,redmine,Ruby,Hook,Redmine,我正在使用Redmine 3.4.6,我需要让它在问题状态更改为特定状态时添加注释。我发现它可以通过保存钩子后的控制器问题编辑来实现,但我找不到任何好的例子来编写控制器钩子。我是Ruby和编码的初学者,所以我请别人解释我必须做些什么才能让它工作。 我的代码: module RedmineAutocomments module Hooks class RedmineAutocommentsHook < Redmine::Hook::ViewListener def

我正在使用Redmine 3.4.6,我需要让它在问题状态更改为特定状态时添加注释。我发现它可以通过保存钩子后的控制器问题编辑来实现,但我找不到任何好的例子来编写控制器钩子。我是Ruby和编码的初学者,所以我请别人解释我必须做些什么才能让它工作。

我的代码:

module RedmineAutocomments
  module Hooks
    class RedmineAutocommentsHook < Redmine::Hook::ViewListener
      def controller_issues_edit_after_save(context={})
        issue = context[:issue]
        trackers = ["Tracker1", "Tracker2", "Tracker3"]
        if trackers.include? @issue.tracker
          if @issue.status == "Ready for handout"
            @comment = Comment.new
            @comment = 'Some comment need to be added'
            @news.comments << @comment
          end
        end
      end
    end
  end
end
模块redmine自动提示
模块挂钩
类RedMineAutommentShake@news.comments一切都不是很困难:

module RedmineAutocomments
  module Hooks
    class RedmineAutocommentsHook < Redmine::Hook::ViewListener
      def controller_issues_edit_after_save(context={})
        @issue = context[:issue]
        case @issue.project.id
        when 9
          case @issue.tracker.id
          when 13, 14, 20
            case @issue.status.id
            when 26
              @issue.notes = MESSAGE
              @issue.save
            end
          end
        end
      end
    end
  end
end
模块redmine自动提示
模块挂钩
类RedMineAutommentShake