我完成了启动和运行操作电缆所需的所有步骤,取消注释电缆线,创建通道,安装redis ..等等 但由于这条线而全部失败
App.cable = ActionCable.createConsumer()
由于我在virtualbox中操作,因此我对网站提出了无效请求。 甚至动作电缆记录都没有工作
module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user
def connect
puts "YOU ARE CONNECTED "
self.current_user = find_verified_user
logger.add_tags 'ActionCable', current_user.email
end
protected
def find_verified_user # this checks whether a user is authenticated with devise
if verified_user = env['warden'].user
verified_user
else
reject_unauthorized_connection
end
end
end
end
我很确定是流浪问题,但我不知道如何修复它,
这是我的流浪文件
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/wily64'
config.vm.hostname = 'rails-dev-box'
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network :forwarded_port, guest: 5432, host: 15432
config.vm.network :forwarded_port, guest: 6379, host: 6379
config.ssh.forward_agent = true
config.vm.provision :shell, path: 'bootstrap.sh', keep_color: true
config.vm.provider 'virtualbox' do |v|
v.memory = 1024
v.cpus = 2
end
end
bootstrap.sh只需安装rvm / rails / postgres ..etc
我甚至关闭了防火墙。我的意思是元标记是正确的
<meta name="action-cable-url" content="/cable">
当我运行App.cable时,我得到了这个
url:"ws://localhost:3000/cable" connection: {disconnected: true}
我的路线中有这个.rb
mount ActionCable.server => '/cable'
我的cable.js是
//= require action_cable
//= require_self
//= require_tree ./channels
(function() {
this.App || (this.App = {});
App.cable = ActionCable.createConsumer();
}).call(this);
和rails控制台没有显示actioncables日志
我使用rails 5默认服务器:
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.6.0 (ruby 2.2.5-p319), codename: Sleepy Sunday Serenity
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop