Ruby on Rails

ActionCable & WebSockets

Real-time features, channels, subscriptions, broadcasting, cable.yml configuration, Redis adapter

18 domande da colloquioยท
Mid-Level
1

What is ActionCable in Ruby on Rails?

Risposta

ActionCable is a framework built into Rails that enables real-time features via WebSockets. It provides a server-side abstraction in Ruby and a client-side abstraction in JavaScript to establish persistent bidirectional connections between the browser and the server. ActionCable integrates naturally with the rest of the Rails application, allowing access to models and other components.

2

Which configuration file defines the adapter used by ActionCable for pub/sub?

Risposta

The cable.yml file located in config/ defines the pub/sub adapter used by ActionCable. This file specifies different adapters per environment: async for development (in-memory, single-process), redis or postgresql for production (enabling communication across multiple processes/servers). The configuration typically includes the Redis server URL and the channel to use.

3

In which directory are ActionCable server-side channels typically placed?

Risposta

ActionCable server-side channels are placed in app/channels/. This directory contains ApplicationCable::Connection (connection management and authentication) and ApplicationCable::Channel (base class for all channels). Custom channels inherit from ApplicationCable::Channel and define the business logic for each type of real-time communication.

4

Which method should be used in a channel to subscribe to a message stream identified by a string?

5

What is the difference between stream_from and stream_for in ActionCable?

+15 domande da colloquio

Padroneggia Ruby on Rails per il tuo prossimo colloquio

Accedi a tutte le domande, flashcards, test tecnici, esercizi di code review e simulatori di colloquio.

Inizia gratis