I am using Faye websockets in my Rails application, just like Railcasts # 260. All was fine, but now I am getting error like
ReferenceError: Faye is not defined
here
$(function() {
var faye = new Faye.Client('http://localhost:9292/faye');
faye.subscribe("/games/messages/new", function(data) {
eval(data)
});
});
I started my faye like: rackup faye.ru -s thin -E production
faye.ru
require 'faye'
Faye::WebSocket.load_adapter('thin')
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)
run faye_server
I don't know what's going on, the only thing I changed was install rails-unicorn gem and default booting from it.
UPDATE: http://localhost:9292/ says:
And if I add /faye -
And if I add /faye.js -
UPDATED: For a now it just works, don't know why, but it is. Thank you, all.
I would suggest you to use your actual ip
instead of localhost
in Faye.Client
initialization in production environment(of course use request.host
helper for this):
var faye = new Faye.Client("http://#{ request.host }:9292/faye");