Ruby on Rails

Rails Engines & Modular Apps

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

18 gespreksvragen·
Senior
1

What is a Rails Engine?

Antwoord

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?

Antwoord

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?

Antwoord

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 gespreksvragen

Beheers Ruby on Rails voor je volgende gesprek

Krijg toegang tot alle vragen, flashcards, technische tests, code review-oefeningen en gespreksimulatoren.

Begin gratis