Why Railtie initializers are not executed?
Asked Answered
C

1

7

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?

Centipede answered 2/5, 2011 at 11:32 Comment(0)
G
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!

Gingivitis answered 8/5, 2012 at 13:50 Comment(1)
Of course. Otherwise config.before_initialize wouldn't have been run as well.Centipede

© 2022 - 2024 — McMap. All rights reserved.