Ruby on Rails

Rails Engines & Modular Apps

Mountable engines, isolated engines, namespacing, gem-based architecture

18 câu hỏi phỏng vấn·
Senior
1

What is a Rails Engine?

Câu trả lời

A Rails Engine is a miniature Rails application that can be mounted within a host application. It allows sharing code (models, controllers, views, routes) between multiple applications or creating isolated and reusable features. Gems like Devise, Sidekiq Web UI and ActiveAdmin are examples of popular engines used in the Rails ecosystem.

2

Which command is used to generate a new mountable Rails Engine?

Câu trả lời

The rails plugin new command with the --mountable option generates a complete engine with its own namespace, isolated routes and folder structure. The --mountable option creates an engine fully isolated from the host application, unlike --full which generates a non-isolated engine sharing the main application's namespace.

3

What is the main difference between a --mountable engine and a --full engine?

Câu trả lời

A --mountable engine is fully isolated with its own namespace (module), its own helpers and routes isolated under a configurable prefix. A --full engine shares the host application's namespace, which can create naming conflicts. The mountable engine's isolation ensures that the engine's classes and routes don't pollute the main application's namespace.

4

How to mount a Rails Engine in the host application's routes.rb file?

5

What is the purpose of the isolate_namespace directive in a Rails Engine?

+15 câu hỏi phỏng vấn

Nắm vững Ruby on Rails cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí