在 rails 中带有动作电缆。未找到订阅 class "AsdfChannel"。 (但那是一个旧项目的频道!)

In rails with action cable. Subscription class not found "AsdfChannel". (But that's a channel from an old project!)

当我制作新节目时

~/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 中(应该是),而不是它的子目录。它在 app/channels 中。

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

为什么我的服务器日志甚至会提到以前项目的频道。应该吗?我怎样才能正确地从我以前的项目中删除频道,以便我的新项目不提及它?

顺便说一下,它并没有阻止我从服务器向客户端广播(从我当前项目的频道,当我添加代码这样做时),但我收到的消息似乎仍然是一个奇怪的错误大部头书。

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

解决方法是关闭我打开的所有在 127.0.0.1:3000 的选项卡,并且只有在服务器启动后才打开这样的 tab/tabs。