RailsプロジェクトでActionCableを使用しようとしていますが、WebSocket接続が確立されているようですが、メッセージは送信されません(pingのみ)。Rails ActionCable "connected"メソッドが呼び出されていない
私のCoffeeScriptではconnected
メソッドを呼び出すことはできません。
これは私のチャンネル定義である:
# app\channels\quiz_data_channel.rb:
class QuizDataChannel < ApplicationCable::Channel
def subscribed
stream_from "quiz_data"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
これは私のCoffeeScriptである:
#app\assets\javascripts\channels\quiz_data.coffee:
App.quiz_data = App.cable.subscriptions.create "QuizDataChannel",
connected: ->
# Called when the subscription is ready for use on the server
console.log "[AC] on click handler called?"
$('btn btn-primary btn-lg').on 'click', console.log "[AC] on click handler called!"
disconnected: ->
# Called when the subscription has been terminated by the server
received: (data) ->
# Called when there's incoming data on the WebSocket for this channel
誰もが、問題が何ができるかのアイデアを持っていますか?
これは私の最初のレールプロジェクトであり、どんな助けにも感謝します。
ありがとうございました。私はWindowsのコンソールではなく、browsertoolsコンソールで探していたので、最初は気付かなかった。_ < – megahra