Why Railtie initializers are not executed?

£可爱£侵袭症+ 提交于 2019-12-08 17:24:38

问题


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?


回答1:


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!



来源:https://stackoverflow.com/questions/5856614/why-railtie-initializers-are-not-executed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!