どうやら Redmine はプラグインの lib は自動的にロードパスに登録するが、app 以下は controllers, models, helpers のみを autoload の対象にするようだ。
lib/redmine/plugin.rb にこんな記述があった。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds the app/{controllers,helpers,models} directories of the plugin to the autoload path | |
Dir.glob File.expand_path(File.join(p.directory, 'app', '{controllers,helpers,models}')) do |dir| | |
ActiveSupport::Dependencies.autoload_paths += [dir] | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Redmine::Plugin.register :hoge do | |
# other plugin settings | |
# simple | |
ActiveSupport::Dependencies.autoload_paths += [File.dirname(__FILE__) + "/app/forms"] | |
# multiple | |
Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), "app", "{forms,services}"))) do |dir| | |
ActiveSupport::Dependencies.autoload_paths += [dir] | |
end | |
end |
0 件のコメント :
コメントを投稿