ruby-on-railsrubyrabbitmqcarrot

Where is the best place initialize a Singleton in Rails?


Where is the best place initialize a Singleton in Rails?

I am using the Carrot AMQP library in a Ruby on Rails app and I only want to initial the settings once and not on every task that is generated.

I currently have it in my environment.rb and it seems to work but I am not entirely sure this is the best place.

Is having Carrot initialized only once Rails has booted even a good idea or should I create a new Carrot object for every task that is created?


Solution

  • # config/initializers/carrot.rb
    
    require 'carrot'
    #set some carrot settings