Ruby on Rails

ActionCable & WebSockets

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

18 คำถามสัมภาษณ์·
Mid-Level
1

What is ActionCable in Ruby on Rails?

คำตอบ

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?

คำตอบ

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?

คำตอบ

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 คำถามสัมภาษณ์

เชี่ยวชาญ Ruby on Rails สำหรับการสัมภาษณ์ครั้งถัดไป

เข้าถึงคำถามทั้งหมด flashcards แบบทดสอบเทคนิค แบบฝึกหัด code review และตัวจำลองสัมภาษณ์

เริ่มใช้ฟรี