Ruby on Rails

Modern Asset Pipeline & Frontend

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

18 面接問題·
Mid-Level
1

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

回答

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?

回答

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?

回答

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 面接問題

次の面接に向けてRuby on Railsをマスター

すべての問題、flashcards、技術テスト、コードレビュー演習、面接シミュレーターにアクセス。

無料で始める