Solid Cable: WebSockets and Real-Time Without Redis
Welcome to the second article in our series on the Solid Triumvirate in Rails 8! Today, we’re tackling a hot topic if you want to build a Rails app that lives in the present: real-time.
✨ Solid Cable is the new way to integrate WebSockets in Rails without wrestling with Redis or external servers. It’s native, it’s simple, and it’s powerful.
But why is real-time so important today? Because your users expect it. Here are some concrete use cases where Solid Cable shines:
- 💬 A live chat between users, without reloading the page
- 📈 A dashboard that updates automatically when data changes
- 🔔 Instant notifications as soon as an event occurs
- 🛒 A shared cart that stays in sync live across multiple devices
- 🎮 A collaborative app where several people interact at the same time
With Solid Cable, all of this becomes possible without friction. In this article, we’ll show how to install it, configure it, and especially how to use it to create dynamic, modern experiences.
Feel free to browse my other articles on the Solid Triumvirate topic that will no longer hold any secrets for you!
- "Solid Cache" : No longer relying on Redis for cache in Rails
- "Solid Cable" : WebSockets and real-time simply and without fuss (you’re here)
- "Solid Queue" : Background tasks Rails-style
- The triumvirate applied to a complete project
This is going to be solid :)
Solid Cable: WebSockets Without Redis in Rails 8
Understanding Action Cable and Real-Time
Action Cable is Rails' solution for adding real-time features to your application. Think of:
- A live chat
- Instant notifications
- Dashboards with live data
- Real-time collaboration (like Google Docs)
How do WebSockets work?
WebSockets are like a phone that’s always off the hook between the client and the server:
Classical HTTP:
WebSocket:
The Role of Solid Cable
Traditionally, Action Cable used Redis as the "central exchange" to route messages between the different processes of your application.
Solid Cable replaces Redis with a database table and a polling system (regular polling).
The Architecture of Solid Cable
Solid Cable creates a simple table:
How it works:
- A client connects via WebSocket
- When a message needs to be sent, it’s written into this table
- A polling system checks regularly (default every 0.1 seconds) for new messages
- The messages are transmitted to the connected clients
- Old messages are automatically deleted after 1 day
Installation and Configuration
On Rails 8
As with Solid Cache, Solid Cable is enabled by default in production on Rails 8!
Check your config/cable.yml:
Development configuration
By default, Rails 8 uses the async adapter in development. To use Solid Cable in dev:
Then configure your config/database.yml:
Complete Example: Real-Time Chat
Let’s build a simple chat application to illustrate Solid Cable.
Step 0: Create a new project
Configure cable.yml to use solid_cable instead of async in development.
In development you need to add the solid_cable database schema to the database. In production, there will be a dedicated database so not needed.
Step 1: Create the model
Step 2: Create the channel
Step 3: The model with broadcast
Step 4: The controller
Step 5: The view
Step 6: Routes
Testing in Action
- Start your server: bin/dev
- Open two browser windows at http://localhost:3000
- Type a message in one window
- See it appear instantly in the other!
This real-time chat relies on Turbo Streams and Solid Cable: the page subscribes to the stream with turbo_stream_from "chat". When a message is submitted via form_with, the controller creates a Message record.
After the commit, the model triggers broadcast_append_to "chat", and Solid Cable (the production adapter of ActionCable) persists and distributes this broadcast.
On the client side, @hotwired/turbo-rails automatically receives the stream and updates the DOM by adding the new message into #messages, with no custom JavaScript and no page reload.
Monitoring and Debugging
Verifying messages in the database
Viewing logs
Solid Cable vs Other Solutions
|
Solution
|
Speed
|
Setup
|
Scalability
|
Use cases
|
|---|---|---|---|---|
|
Solid Cable
|
Good
|
Very simple
|
Medium
|
Small/medium apps
|
|
Action Cable (Redis)
|
Very good
|
Simple
|
Good
|
Medium apps
|
|
AnyCable
|
Excellent
|
Complex
|
Excellent
|
Large-scale apps
|
Use Solid Cable if:
- You’re starting a new Rails 8 app
- You need basic real-time features
- You want to avoid Redis
- You have fewer than 1000 concurrent connections
Switch to Action Cable + Redis if:
- You need better performance
- You already have Redis in your stack
Switch to AnyCable if:
- You have thousands of concurrent connections
- Latency is critical
Conclusion: Solid Cable, Real-Time Without Compromise
Solid Cable redefines how we think about real-time in Rails. No more complex setups with Redis or external servers: everything runs locally, with seamless integration and a familiar API. Whether it’s a chat, notifications, dashboards, or collaborative experiences, Solid Cable lets you build reactive, modern interfaces without sacrificing simplicity.
With Rails 8 officially adopting it, Solid Cable becomes an essential tool for any developer who wants to deliver a dynamic and instant user experience.
⚡ Fewer dependencies, more interactions. Solid Cable is Rails in real-time, as it should be.
