App.cable.subscriptions.create("ChannelName", {
received(data) {
console.log(data);
}
});
def update_counter(data)
ActionCable.server.broadcast 'channel_name', my_data: data
end
class MyController < ApplicationController
def update
# 更新数据库
# 从数据库中获取新数据
ActionCable.server.broadcast 'channel_name', my_data: data
end
end