@ibugs 网站是不是挂了。。。。。
已读,受益匪浅
新年快乐。。。。。。哈
#1 楼 @jimrokliu 嗯嗯,谢谢,我也通过变通实现了这个需求,解决不了只好先绕过去。。
解决了 https://github.com/jamesotron/faye-rails/issues/58
回来结贴,修改 gem faye-rails lib/faye-rails/middleware.rb
options = DEFAULTS.merge(options)
- Faye::WebSocket.load_adapter(options.delete(:server))
+ server = options.delete(:server)
+ Faye::WebSocket.load_adapter(server) if server && server != 'passenger'
@adapter = FayeRails::RackAdapter.new(@app, options)
@adapter.instance_eval(&block) if block.respond_to? :call
在 appllication 下配置为
config.middleware.use FayeRails::Middleware, mount: '/faye', :timeout => 25,server:'passenger', engine: {type: Faye::Redis, host: 'localhost'} do
map '/chat' => RealtimeChatController
map default: :block
end
会 error.log 报这个错
cannot load such file -- passenger (LoadError)
/var/lib/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
/var/lib/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `block in require'
/var/lib/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
/var/lib/gems/1.9.1/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in `require'
/var/lib/gems/1.9.1/gems/faye-websocket-0.9.2/lib/faye/websocket.rb:42:in `load_adapter'
/var/lib/gems/1.9.1/gems/faye-rails-2.0.0/lib/faye-rails/middleware.rb:44:in `initialize'
/var/lib/gems/1.9.1/gems/actionpack-4.1.4/lib/action_dispatch/middleware/stack.rb:43:in `new'
/var/lib/gems/1.9.1/gems/actionpack-4.1.4/lib/action_dispatch/middleware/stack.rb:43:in `build'
/var/lib/gems/1.9.1/gems/actionpack-4.1.4/lib/action_dispatch/middleware/stack.rb:118:in `block in build'
/var/lib/gems/1.9.1/gems/actionpack-4.1.4/lib/action_dispatch/middleware/stack.rb:118:in `each'
/var/lib/gems/1.9.1/gems/actionpack-4.1.4/lib/action_dispatch/middleware/stack.rb:118:in `inject'
/var/lib/gems/1.9.1/gems/actionpack-4.1.4/lib/action_dispatch/middleware/stack.rb:118:in `build'
/var/lib/gems/1.9.1/gems/railties-4.1.4/lib/rails/engine.rb:498:in `app'
/var/lib/gems/1.9.1/gems/railties-4.1.4/lib/rails/application/finisher.rb:36:in `block in <module:Finisher>'
/var/lib/gems/1.9.1/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `instance_exec'
/var/lib/gems/1.9.1/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `run'
/var/lib/gems/1.9.1/gems/railties-4.1.4/lib/rails/initializable.rb:55:in `block in run_initializers'
/usr/lib/ruby/1.9.1/tsort.rb:150:in `block in tsort_each'
/usr/lib/ruby/1.9.1/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
/usr/lib/ruby/1.9.1/tsort.rb:219:in `each_strongly_connected_component_from'
/usr/lib/ruby/1.9.1/tsort.rb:182:in `block in each_strongly_connected_component'
/usr/lib/ruby/1.9.1/tsort.rb:180:in `each'
/usr/lib/ruby/1.9.1/tsort.rb:180:in `each_strongly_connected_component'
/usr/lib/ruby/1.9.1/tsort.rb:148:in `tsort_each'
/var/lib/gems/1.9.1/gems/railties-4.1.4/lib/rails/initializable.rb:54:in `run_initializers'
/var/lib/gems/1.9.1/gems/railties-4.1.4/lib/rails/application.rb:300:in `initialize!'
/home/tlt/work/faye-rails-demo-master/config/environment.rb:5:in `<top (required)>'
config.ru:3:in `require'
config.ru:3:in `block in <main>'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
/var/lib/gems/1.9.1/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
config.ru:1:in `new'
config.ru:1:in `<main>'
/var/lib/gems/1.9.1/gems/passenger-4.0.57/helper-scripts/rack-preloader.rb:112:in `eval'
/var/lib/gems/1.9.1/gems/passenger-4.0.57/helper-scripts/rack-preloader.rb:112:in `preload_app'
/var/lib/gems/1.9.1/gems/passenger-4.0.57/helper-scripts/rack-preloader.rb:158:in `<module:App>'
/var/lib/gems/1.9.1/gems/passenger-4.0.57/helper-scripts/rack-preloader.rb:29:in `<module:PhusionPassenger>'
/var/lib/gems/1.9.1/gems/passenger-4.0.57/helper-scripts/rack-preloader.rb:28:in `<main>'
有人碰到过这种问题么,求助啊
试着配置 nginx,会报错 WebSocket connection to 'ws://192.168.1.107/faye' failed: Error during WebSocket handshake: Unexpected response code: 301
location /faye/ {
proxy_pass http://192.168.1.107;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
#1 楼 @jimrokliu nginx version: nginx/1.6.0 websocket 该如何配置,有没有推荐的网址,谢谢
大赞,很漂亮
我是来看妹子的
39681
楼主,我竟然看完了,你还有没有节草......
@moliliang 不知道如何解决的?同样的问题,同纠结
看着不错,mark 一下
<p><%= link_to "站内信",check_messages_path,:style => "color:red" %>
routes
get 'check_messages'=>'users#check_messages'
这个会执行两次,如果只是刷新 check_messages 页面的话是只执行一次
def check_messages
@messages=Message.where(:receive => current_user.id.to_s).order(id: :desc)
for i in @messages
if i.status_one=="1"
i.status="1"
else
i.status_one="1"
end
i.save
end
end
#6 楼 @kai209209 我试了,如果注释掉
gem 'turbolinks'
//= require turbolinks
方法只执行一次,可以实现,turbolinks 应该是最新的,不知道具体原因. 看了@Rei 的这篇文章 http://chloerei.com/2013/07/14/turbolinks-guide/ 不知道@Rei 清楚么
for i in @messages
if i.status_one=="1"
i.status="1"
else
i.status_one="1"
end
i.save
end
我这里想要实现的效果是站内信的功能,@messages为从数据库取出符合的信息,第一次接收到信息并进去 messages 页面,信息标志为 new,再次刷新页面,信息标志为已读,status_one 默认为空,不知道为何会执行两次,直接就置为已读状态,后来我又添加了一个属性,功能是可以实现了
for i in @messages
if i.sender=="1"
if i.status_one=="1"
i.status="1"
else
i.status_one="1"
end
i.save
else
i.sender="1"
end
代码写的不好看,见谅
可以用paperclip
mark 一下,最近正在看元编程,看完之后再看这个
赞一个,想学学 mruby
88
谢谢大家的热心回答,了解了下 moxie,由于时间的关系没有使用,后来使用了@aptx4869 提供的 js,可能是新手的原因,很多地方弄不很清楚,弄了两天也没有达到需求,由于时间关系今天不得已放弃这个了想法,又回到的继续先上传在处理的方式,如果最近能有时间会继续回头做做这块,再次谢谢大家