💎 Ruby on Rails
Intermediate
What is ActionCable in Rails?
Answer
ActionCable integrates WebSockets into Rails, enabling real-time features. The server maintains persistent connections to clients. You define channels (like controllers for WebSockets) in app/channels/. Clients subscribe to channels via JavaScript. The server broadcasts messages: ActionCable.server.broadcast("notifications_channel", message: "You have a new notification"). ActionCable integrates with Pub/Sub adapters (Redis in production, async in development). Use cases: live chat, notifications, collaborative editing, live sports scores, and real-time dashboards.