为什么不执行 Railtie 初始化程序? [英] Why Railtie initializers are not executed?

查看:58
本文介绍了为什么不执行 Railtie 初始化程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在制作 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆