我尝试在滑轨5上操作电缆。
我在routes.rb
中添加了安装点。
mount ActionCable.server, at: "/cable"
我还在application.html.slim
中添加了元标记:
= action_cable_meta_tag
我也尝试像这样编辑development.rb
:
config.action_cable.url = "ws://localhost:3000/cable"
config.action_cable.allowed_request_origins = [/http:\/\/*/, /https:\/\/*/]
这是我的cable.js
:
//= require action_cable
//= require_self
//= require_tree ./channels
(function() {
this.App || (this.App = {});
App.cable = ActionCable.createConsumer();
}).call(this);
还有application.js
:
//= require pagy
//= require jquery
//= require jquery_ujs
//= require popper
//= require bootstrap
//= require activestorage
//= require select2
//= require_tree .
但是当我在开发人员工具中打开“控制台”选项卡时,仍然出现错误:
WebSocket connection to 'ws://localhost:3000/cable' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
我在服务器上找到了登录名,看来一切都可以在服务器上运行,但是在客户端Web套接字上却不起作用。