Ruby on Rails

ActionCable & WebSockets

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

18 pertanyaan wawancaraยท
Mid-Level
1

What is ActionCable in Ruby on Rails?

Jawaban

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?

Jawaban

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?

Jawaban

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 pertanyaan wawancara

Kuasai Ruby on Rails untuk wawancara berikutnya

Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.

Mulai gratis