Websocket rails cannot broadcast from model

I have a problem using websocket-rails harness in rails4 application.
The problem is I can't stream my models.

see my model:

class Diffusion < ActiveRecord::Base
  after_create            :ws_update

  def ws_update
    WebsocketRails[:diffusions].trigger 'diffusions.new', {test: self.id}.to_json
  end
end

      

from another rb file located under the lib folder I call this:

Diffusion.create(some_params)

      

I know for sure that my funtion ws_update was called and I even see the logs in the log / websockets_rails.log that the message was sent.

There is my coffee / script that should handle the message in my webpage

dispatcher = new WebSocketRails("localhost:3000/websocket")
channel = dispatcher.subscribe("diffusions")
channel.bind "diffusions.new", (data) ->
  console.log "GOT DATAAAAAAA"
  return

      

The "GOT DATAAAA" line never shows up, can you explain to me why?

thank

+3


source to share


1 answer


Read here: https://github.com/websocket-rails/websocket-rails/blame/712fd4e35325887956724be388821121a866c7fc/README.md#L177



Channeling from anywhere in the Rails application. An existing controller, model , background work, or new WebsocketRails Controller.

+1


source







All Articles