Project

General

Profile

Can it autoload?

Added by Haihan Ji over 7 years ago

When I modify a patch module, I have to restart the server to make it work?
Any methods to avoid restart?

Below is example

plugins/foo/init.rb

require 'foo/issue_patch'

Redmine::Plugin.register :foo do
  name 'Foo 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'
end

plugins/foo/lib/foo/issue_patch.rb

require_dependency 'issue'
module Foo
  module IssuePatch
    extend ActiveSupport::Concern

    def some_method
      # code
    end

  end
end

unless Issue.included_modules.include?(Foo::IssuePatch)
  Issue.send(:include, Foo::IssuePatch)
end

When I modify issue_patch.rb, I hope it work immediately, don't need restart rails server, development mode.