我已经设置了我的Faye服务器,与我的rails服务器一起运行,就像本教程告诉我: http://net.tutsplus.com/tutorials/ruby/how-to-use-faye-as-a-real-time-push-server-in-rails/
没有奇怪的行为,直到我取消注释该行
var client = new Faye.Client('http://localhost:9292/faye');
然后,Firebug在这个问题的标题中给出了错误。访问localhost:9292 / faye和/faye.js给了我所期望的内容,并且(显然)javascript_include_tag引用该.js文件没有任何问题。
当我启动faye时,我必须使用bundle exec,根据此错误消息:
$ rackup ./config.ru -E production -s thin -p 9292
/Users/newcreation/.rvm/gems/ruby-1.9.3-p0@global/gems/bundler-1.0.21/lib/bundler/runtime.rb:31:in ``block in setup': You have already activated rack 1.4.1, but your Gemfile requires rack 1.3.0. Using bundle exec may solve this. (Gem::LoadError)
我的config.ru看起来像这样:
require 'rubygems'
require 'bundler'
Bundler.require
require 'faye'
require File.expand_path('../config/initializers/faye_token.rb', __FILE__)
faye_server = Faye::RackAdapter.new(:mount => '/faye', :timeout => 45)
run faye_server
有什么想法吗?
由于
答案 0 :(得分:6)
显然,您至少需要0.7版来支持websockets。 http://blog.jcoglan.com/2011/11/28/announcing-faye-websocket-a-standards-compliant-websocket-library/这意味着为我更新rubygems,并重新运行bundle install。我还需要更改我的.ru文件以包含以下内容:
Faye::WebSocket.load_adapter('thin')