rails6 Actionable websocket环境搭建(以聊天室为例)

首先保证rails项目已经创建好了
然后进入该项目的根目录
1、输入 rails g channel chat
建立一个名为chat的channel 这个功能是rails提供的

image.png

2、输入yarn add jquery 安装jquery


image.png

3、rails webpacker:install 安装webpacker


image.png

环境搭建完毕

下面介绍rails项目中的配置文件(未完待续)
首先修改 ./app/channel/chat_channel.rb
增加一行stream_from "chat_channel"
这是要广播的channel


image.png

你可能感兴趣的:(rails6 Actionable websocket环境搭建(以聊天室为例))