为什么不执行 Railtie 初始化程序? [英] Why Railtie initializers are not executed?
问题描述
在制作 Passenger-Monit 插件时,我认为它最适合使用初始化器,即
<预><代码>乘客监控模块类 Railtie <Rails::Railtie初始化程序my_plugin.some_init_task"做# 我的初始化任务结尾结尾结尾然而,由于某种原因,块中的代码从未执行过.我终于解决了
config.before_initialize {}
但我很好奇,为什么不执行初始化程序.什么可能阻止它运行?
在您的 gemfile 中,您是否添加了
gem "Passenger-Monit"
否则你需要把它放在你的加载路径中并在你的应用程序中要求它.http://www.igvita.com/2010/08/04/rails-3-internals-railtie-creating-plugins/
祝你好运!
While crafting the Passenger-Monit plugin, I thought that it'll be most appropriate to use the initializer, i.e.
module PassengerMonit
class Railtie < Rails::Railtie
initializer "my_plugin.some_init_task" do
# my initialization tasks
end
end
end
However, for some reason the code in the block was never executed. I finally made a work-around with
config.before_initialize {}
but I'm curious, why the initializer wasn't executed. What could have prevented it from running?
In your gemfile, did you add
gem "Passenger-Monit"
Otherwise you need to put it in your load path and require it in your application. http://www.igvita.com/2010/08/04/rails-3-internals-railtie-creating-plugins/
Good luck!
这篇关于为什么不执行 Railtie 初始化程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!