title: "Subscription class not found" with ActionCable and Rails 6 API
body: <p>I use <code>ruby 3.0.2p107</code>, <code>Rails 6.1.6</code> and I've a Rails backend (API) and a React Typescript frontend.</p>
  <p><strong>Backend code</strong></p>
  <pre><code># app/channels/notification_channel.rb
  class NotificationChannel &lt; ApplicationCable::Channel
    def subscribed
      stream_from &quot;notification_channel_#{current_user.user_id}&quot;
    end
  
    def unsubscribed; end
  end
  </code></pre>
  <pre><code># app/channels/application_cable/connection.rb
  module ApplicationCable
    class Connection &lt; ActionCable::Connection::Base
      identified_by :current_user
  
      def connect
        self.current_user = find_user
      end
  
      private 
  
      # search the current user
      def find_user
        current_user = Profile::Account.find_by(user_id: request.query_parameters[:user_id])
        current_user ? current_user : reject_unauthorized_connection
      end
    end
  end
  </code></pre>
  <p><strong>Frontend code</strong></p>
  <pre><code>    const createSubscription = (consumer: ActionCable.Cable) =&gt; {
          consumer.subscriptions.create({ channel: `notification_channel_${user.sub}` }, {
              connected: () =&gt; console.log(`connected to notifications.${user.sub}`),
              received: (notification) =&gt; handleReceivedNotification(notification),
          });
      };
  
      const handleReceivedNotification = (notification: any) =&gt; {
          console.log(JSON.stringify(notification));
      }
  
      useEffect((): void =&gt; {
          if (user) setComsumer(ActionCable.createConsumer(`ws://localhost:3100/cable?user_id=${user.sub}`));
      }, [user]);
  
      useEffect((): void =&gt; {
          if (consumer) createSubscription(consumer);
      }, [consumer]);
  </code></pre>
  <p>When I run the app (backend and frontend) I get the connection but can't find the subscription class.</p>
  <pre><code>Registered connection (Z2lkOi8vYXBpL1Byb2ZpbGU6OkFjY291bnQvMQ)
  Subscription class not found: &quot;notification_channel_facebook|10157537128720479&quot;
  </code></pre>
  <p>Also if I try a broadcast from command line, it does not work out (returns 0).</p>
  <pre><code>$ ActionCable.server.broadcast &quot;notification_channel_#{user.user_id}&quot;, { action: &quot;new_notification&quot; }
  D, [2022-07-07T14:44:03.820530 #19220] DEBUG -- : [ActionCable] Broadcasting to notification_channel_facebook|10157537128720479: {:action=&gt;&quot;new_notification&quot;}
  =&gt; 0
  </code></pre>
  <p>I checked also the Redis channels but I can't find the <code>notification_channel</code>.</p>
  <pre><code>Redis.new.pubsub(&quot;channels&quot;)
  =&gt; [&quot;action_cable/Z2lkOi8vYXBpL1Byb2ZpbGU6OkFjY291bnQvMQ&quot;, &quot;_action_cable_internal&quot;]
  </code></pre>
  <p>Here my <code>config/cable.yml</code> config file</p>
  <pre><code>default: &amp;default
    adapter: redis
    url: redis://localhost:6379/1
  
  development:
    &lt;&lt;: *default
  
  test:
    &lt;&lt;: *default
  
  production:
    adapter: redis
    url: &lt;%= ENV['REDIS_URL'] %&gt;
    channel_prefix: api_production
  </code></pre>
  <p>Here the imports of <code>config/application.rb</code></p>
  <pre><code>
  require &quot;rails&quot;
  # Pick the frameworks you want:
  require &quot;active_model/railtie&quot;
  require &quot;active_job/railtie&quot;
  require &quot;active_record/railtie&quot;
  require &quot;active_storage/engine&quot;
  require &quot;action_controller/railtie&quot;
  require &quot;action_mailer/railtie&quot;
  require &quot;action_view/railtie&quot;
  require &quot;action_cable/engine&quot;
  # require &quot;sprockets/railtie&quot;
  require &quot;rails/test_unit/railtie&quot;
  # activate the action mailer system
  require &quot;active_storage/engine&quot;
  require &quot;action_mailbox/engine&quot;
  </code></pre>
  <p>I believe I've been through all the documentation I could find about the topic, but I'm starting loose on options. Any help would be really appreciated.</p>
  <p>Thanks</p>