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