Bijendra
Bijendra

Reputation: 10015

Rails initializer file not loading in production environment

I have patched websocket-rails gem to work in my development setup.

I created a file websocket_patch.rb under config/initializers and copied the code from websocket-rails-0.7.0\lib\rails\app\controllers\websocket_rails\delegation_controller.rb

module WebsocketRails
  class DelegationController < ApplicationController
  end
end

The namespace Namespace1 has been added to reference the file and match up with my project structure.

Current project structure is like 

Project folder
      |_namespace1-/app/../application_controller.rb
      |_namespace2-/app/../application_controller.rb

So i have to override the default access in delegation_controller.rb.

  Project folder
     |_config/initializers/websocket_patch.rb

  module WebsocketRails
    class DelegationController < Namespace1::ApplicationController
    end
  end

It works properly in development enviroment but breaks in production. It goes back to gem file for the reference instead of loading the file under config/initalizers

websocket-rails-0.7.0/lib/rails/app/controllers/websocket_rails/delegation_controller.rb:11:in `<module:WebsocketRails>': uninitialized constant WebsocketRails::ApplicationController (NameError)   

Rails version: 3.2.22.4, Ruby version: 2.2, there is no specific configuration in production for loading the initailizers. Let me know if you need more info around this

Upvotes: 3

Views: 345

Answers (0)

Related Questions