rails 版本 5.0.6
class RoomChannel < ApplicationCable::Channel
def subscribed
stream_from "room_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
end
App.room = App.cable.subscriptions.create "RoomChannel",
connected: ->
disconnected: ->
received: (data) ->
alert (data.message)
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap
//= require_tree .
ActionCable.server.broadcast 'room_channel',{message: 'asdfasdf'}
刚接触 Action Cable,这个问题出的莫名其妙。。。希望有大佬,可以帮帮我!
是由于 application.js 中
//= require bootstrap
引起去掉就可以了