I am trying to use a pushing mechanism using websocket-rails gem in ROR application.
I have basically done the folowing.
my application.js
//= require jquery
//= require jquery_ujs
//= require websocket_rails/main
$(function(){
// connect to server like normal
var dispatcher = new WebSocketRails('localhost:3000/websocket');
// subscribe to the channel
var channel = dispatcher.subscribe('products');
// bind to a channel event
channel.bind('new', function(data) {
console.log('channel event received: ' + data);
});
});
then I started thin server at port 3000
Then I from rails console, I entered the following command.
WebsocketRails[:products].trigger(:new, Product.last)
But nothing was printed in browser console.
Have I missed some setup configuration?
Thanks