Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/phawk/action-cable-online-status
YouTube episode demonstrating how to show which users are online using action cable
https://github.com/phawk/action-cable-online-status
Last synced: 2 months ago
JSON representation
YouTube episode demonstrating how to show which users are online using action cable
- Host: GitHub
- URL: https://github.com/phawk/action-cable-online-status
- Owner: phawk
- License: mit
- Created: 2023-01-15T11:19:17.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-01-15T14:12:55.000Z (almost 2 years ago)
- Last Synced: 2024-04-11T15:29:09.929Z (9 months ago)
- Language: Ruby
- Size: 134 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Online status using action cable
This is a demo app to show you how to show the current online state of a user using ActionCable.
## Creating the project
This project was generated using the following command.
```sh
rails new online_status --skip-jbuilder --skip-test --css=tailwind --javascript=esbuild
```## Running the project
To get set up, run the `bin/setup` script, to install dependencies, create the database, migrate and seed it with some sample data.
Then run `bin/dev` and `open localhost:3000`.
## Creating the action cable channel
```sh
$ bin/rails g channel Online
```### Making User.rb "live"
Add this to the top of the model
```ruby
after_update_commit { broadcast_replace_to("online_users") }
```And this to your view file that you want to listen for changes
```ruby
<%= turbo_stream_from "online_users" %>
```### License
This code is licensed under the MIT License.