Ruby on rails &引用;“未找到订阅类别”;ActionCable的问题

Ruby on rails &引用;“未找到订阅类别”;ActionCable的问题,ruby-on-rails,ruby-on-rails-5,actioncable,Ruby On Rails,Ruby On Rails 5,Actioncable,我使用Rails 5.1.5,我有以下代码 app/channels/application\u cable/channel.rb module ApplicationCable class Channel < ActionCable::Channel::Base end end module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :curr

我使用Rails 5.1.5,我有以下代码

app/channels/application\u cable/channel.rb

module ApplicationCable
  class Channel < ActionCable::Channel::Base
  end
end
module ApplicationCable
  class Connection < ActionCable::Connection::Base
    identified_by :current_user
    def connect
      self.current_user = find_verified_user
      logger.add_tags 'ActionCable', current_user.slug
    end
    private
    def find_verified_user
      if verified_user = env['warden']&.user
        verified_user
      else
        reject_unauthorized_connection
      end
    end
  end
end
class NotificationsCountChannel < ApplicationCable::Channel
  def subscribed
  end
end
客户端可以成功连接到位于“/cable”默认路径的WebSocket。但是订阅NotificationsOntChannel并不成功。以下是日志:

Started GET "/cable" for 127.0.0.1 at 2018-02-24 20:50:31 +0300
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2018-02-24 20:50:31 +0300
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
Subscription class not found: "NotificationsCountChannel"
此外,我无法在rails控制台中检查
NotificationScontChannel

namererror(未初始化的常量notificationscontchannel)

看起来Rails没有加载NotificationsOntChannel类。
运行
bin/rails r'会放置ActiveSupport::Dependencies。自动加载路径'
会提供不包含
app/channels
的路径列表。可通过添加
config.autoload_路径+=%W(#{config.root}/app/services)
到config/application.rb,但它不能解决主要问题


我错过了什么?

答案很简单:注意力不集中。
实际上,
channels
dir位于项目的根目录中,而不是
app
dir中

Started GET "/cable" for 127.0.0.1 at 2018-02-24 20:50:31 +0300
Started GET "/cable/" [WebSocket] for 127.0.0.1 at 2018-02-24 20:50:31 +0300
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
Subscription class not found: "NotificationsCountChannel"