Javascript Rails 5 ActionCable未接收数据已接收方法未调用

Javascript Rails 5 ActionCable未接收数据已接收方法未调用,javascript,ruby-on-rails,ruby,websocket,actioncable,Javascript,Ruby On Rails,Ruby,Websocket,Actioncable,当我在产品页面中发布新的评论时,所有登录该页面的用户都会收到一条警告,并且该评论也会在不刷新页面的情况下出现 当此频道ProductChannel的websocket上有传入数据时,应该调用product.js中接收的函数,但不会发生任何事情。你知道有什么问题吗 App.product = App.cable.subscriptions.create("ProductChannel", { connected: function() { // Called when the subs

当我在产品页面中发布新的评论时,所有登录该页面的用户都会收到一条警告,并且该评论也会在不刷新页面的情况下出现

当此频道ProductChannel的websocket上有传入数据时,应该调用product.js中接收的函数,但不会发生任何事情。你知道有什么问题吗

App.product = App.cable.subscriptions.create("ProductChannel", {
  connected: function() {
    // Called when the subscription is ready for use on the server
  },

  disconnected: function() {
    // Called when the subscription has been terminated by the server
  },

  received: function(data) {
    // Called when there's incoming data on the websocket for this channel
    $('.alert.alert-info').show().delay(3000).fadeOut('slow');
    $('.product-reviews').prepend(data.comment);
    $("#average-rating").attr('data-score', data.average_rating);
    refreshRating();
  },

  listen_to_comments: function(){
    return this.perform('listen', {
      product_id: $("[data-product-id]").data("product-id")
    });
  }
});

$(document).on('turbolinks:load', function() {
  App.product.listen_to_comments();
});
product_channel.rb

class ProductChannel < ApplicationCable::Channel
  def subscribed
    # stream_from "some_channel"
    # stream_from "product_channel"
  end

  def unsubscribed
    # Any cleanup needed when channel is unsubscribed
  end

  def listen(data)
    stop_all_streams
    stream_for data["product_id"]
  end
end
class ProductChannel
注释\u controller.rb

class CommentsController < ApplicationController

  def index
    redirect_to root_path
  end

  def create
    @product = Product.find(params[:product_id])
    @comment = @product.comments.new(comment_params)
    @comment.user = current_user
    respond_to do |format|
      if @comment.save
        ProductChannel.broadcast_to @product.id, comment: CommentsController.render(partial: 'comments/comment', locals: {comment: @comment, current_user: current_user}), average_rating: @product.average_rating
        format.html { redirect_to @product, notice: 'Review was created successfully.' }
        format.json { render :show, status: :created, location: @product }
        format.js
      else
        format.html { redirect_to @product, alert: 'Review was not saved successfully.' }
        format.json { render json: @comment.errors, status: :unprocessable_entity }
      end
    end
  end
class CommentsController

我还遇到了这个错误,无法处理ProductChannel#listen({“product_id”=>9})

有什么好运气吗?我也遇到了一般性的错误。