Building a Rails Engine #11 -- Generators: Install & Target Scaffolding
Generators: Install & Target Scaffolding A great gem installs in one command. A great engine scaffolds new import types from the command line. Here is how to build Rails generators that bootstrap everything -- migration, initializer, routes, and per-target files -- so adopters never have to wire anything by hand. Context This is part 11 of the series where we build DataPorter , a mountable Rails engine for data import workflows. In part 10, we built the ImportsController, wired up engine routes, and solved the dynamic parent controller inheritance problem. At this point the engine is feature-complete: targets, sources, the orchestrator, real-time progress, a Phlex UI, and controllers all work together. But onboarding a new host app still requires manually creating a migration, writing an initializer, mounting the engine in routes, and knowing the exact Target DSL to define an import type. That is too many steps for someone evaluating the gem for the first time. We need generators that
Continue reading on Dev.to Webdev
Opens in a new tab



