Ruby on Rails

Modern Asset Pipeline & Frontend

Importmap-rails (Rails 7+), jsbundling/cssbundling, Hotwire (Turbo + Stimulus), Sprockets (legacy)

18 pytań z rozmów·
Mid-Level
1

What is the default asset management system in Rails 7+?

Odpowiedź

Importmap-rails is the default system in Rails 7+ for managing JavaScript files. It allows using native ES modules directly in the browser without a bundling step, by mapping package names to CDN URLs or local files. This significantly simplifies frontend configuration while eliminating the Node.js dependency.

2

How to add an external JavaScript library with Importmap-rails?

Odpowiedź

The bin/importmap pin command adds a JavaScript library to the config/importmap.rb file. This command automatically resolves the package from jspm.io or a CDN and adds the corresponding mapping. For example, bin/importmap pin lodash adds the pin line for lodash pointing to the CDN.

3

Which Rails helper to use for including JavaScript scripts defined in the importmap?

Odpowiedź

The javascript_importmap_tags helper generates the necessary tags to load the importmap and JavaScript entry point. It produces a script tag type='importmap' containing the mappings, as well as a tag to load the application.js file. This helper replaces javascript_pack_tag used with Webpacker.

4

What is the main difference between jsbundling-rails and cssbundling-rails?

5

What is the main role of Turbo Drive in Hotwire?

+15 pytań z rozmów

Opanuj Ruby on Rails na następną rozmowę

Uzyskaj dostęp do wszystkich pytań, flashcards, testów technicznych, ćwiczeń code review i symulatorów rozmów.

Zacznij za darmo