在带有动作电缆的导轨中。找不到订阅类“ AsdfChannel”。 (但这是一个旧项目的频道!)

时间:2019-04-21 01:29:40

标签: ruby-on-rails actioncable

当我制作新程序时

~/myrubythings$ rails new channeltest3 
....

~/myrubythings$ cd channeltest3

~/myrubythings/channeltest3$ rails generate channel cvbnm
Running via Spring preloader in process 2837
      create  app/channels/cvbnm_channel.rb
   identical  app/assets/javascripts/cable.js
      create  app/assets/javascripts/channels/cvbnm.coffee
~/myrubythings/channeltest3$ rails s
=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.5.0-p0), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop
Started GET "/cable" for 127.0.0.1 at 2019-04-21 02:15:56 +0100
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2019-04-21 02:15:56 +0100
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
Subscription class not found: "AsdfChannel"
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2019-04-21 02:16:00 +0100 ===
- Goodbye!
Exiting

注意,我收到此消息Subscription class not found: "AsdfChannel"

~/myrubythings/channeltest3$ grep -irl asdf ./
.//log/development.log
~/myrubythings/channeltest3$ 

~/myrubythings/channeltest3$ grep -i asdf log/development.log 
Subscription class not found: "AsdfChannel"
~/myrubythings/channeltest3$ 

这个全新项目中甚至提到AsdfChannel的唯一文件是服务器的日志文件!

它正在从我之前从事的项目(channtest2)中获取一个频道

~/myrubythings/channtest2$ grep -irl AsdfChannel ./
.//app/assets/javascripts/channels/asdf.coffee
.//app/channels/asdf_channel.rb
....

但是我当前的项目(channeltest3)没有提及AsdfChannel或asdf_channel.rb

我检查了Subscription class not found 'MyChannel' in ActionCable,它提到要检查通道的rb文件是否在app / channels中(应该是),而不是其子目录中。它在应用程序/频道中。

~/myrubythings/channeltest3$ ls app/channels/
application_cable   cvbnm_channel.rb
~/myrubythings/channeltest3$ 

为什么我的服务器日志甚至提到以前项目中的频道。应该是吗我又该如何适当地从先前的项目中删除该频道,以使我的新项目不会提及它?

顺便说一句,这并不能阻止我从服务器向客户端广播(从我当前项目的频道,当我添加代码时),但是我得到的消息仍然对我来说似乎是一个奇怪的错误。

1 个答案:

答案 0 :(得分:0)

事实证明,我从一个使用actioncable的旧项目中打开了一个选项卡,即使我关闭了服务器,并为当前运行的服务器启动了一个新选项卡,打开的旧选项卡仍然有效。

解决方案是关闭我已打开的所有位于127.0.0.1:3000的选项卡,并仅在服务器启动后打开此类选项卡。