Skip to main content

How this Gem's assets and views are loaded

This app needs only to be initialized for its assets and views to be added to their respective Rails paths. This works without any explicit directive in this Gem's code. You would be justified in demanding an answer to how this works.

Engines?

Though poorly documented and never clearly stated, Rails Engines add their assets when loaded as Gems, and their views to the respective paths. This Gem does not serve the traditional role of an engine and does not need to be mounted—initializing it is enough for Rails to count it as an Engine. This is because the initialization script for this Gem declares that it contains a class inheriting from Rails::Engine.

All of this is done without explicit namespacing or configuration. For instance, since no application.html.erb layout file is found in your app, this Gem's layout is used automatically. Rails consults all loaded paths after failing to locate the view locally, including any known Engines.

Magic! Frustrating to discover, but magic nonetheless.