jimsynz / faye-rails

Simple Rails glue for the Faye messaging protocol.
MIT License
435 stars 79 forks source link

Subscription with sidekiq-jobs #82

Open dduft opened 9 years ago

dduft commented 9 years ago

I added FayeRails and Sidekiq to my rails4 project and tried to use faye subscription with sidekiq-jobs like this:

class FayeMessagesController < FayeRails::Controller
    channel '/inspections/inspect_indices' do
        subscribe do
            Rails.logger.info "FayeMessagesController: Received on channel #{channel}: #{inspect}"
             IndexInspectionsWorker.perform_async
        end
    end
end

Works fine for some time but from time to time, when i change code and reload browser i get the following error:

/home/signify/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:479:in `load_missing_constant': A copy of FayeMessagesController has been removed from the module tree but is still active! (ArgumentError)
    from /home/signify/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/activesupport-4.2.3/lib/active_support/dependencies.rb:184:in `const_missing'
    from /home/signify/Projects/chunks/app/realtime/faye_messages_controller.rb:21:in `block (2 levels) in <class:FayeMessagesController>'
    from /home/signify/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/faye-rails-2.0.1/lib/faye-rails/controller/channel.rb:47:in `instance_eval'

In general i found a solution but i have no glue how to fix this in that specific case:

http://stackoverflow.com/a/23008837/2560683

Any ideas?