Rails Site Engine
Rails Site Engine is a Rails Engine for production-ready brochure/business websites.
Responsibilities
- Engine (
rails_site_engine): layout, section rendering, SEO defaults, contact flow, shared helpers. - Host app (client site): runtime shell +
config/site_engine.yml+ client-owned content files.
Canonical Local Workflow
1) Engine development harness (CI-style)
Use test/dummy only for engine development and tests.
bin/setup
bin/dev
Dummy app URL: http://localhost:3000
2) Real host-app validation (recommended)
Create real client apps under client_projects/.
bin/new_client_project acme-plumbing --site-profile=home-services --trade-specialty=plumbing --business-name="Acme Plumbing"
This command:
- Creates
client_projects/acme-plumbing. - Generates a minimal Rails host app (PostgreSQL + importmap + Propshaft).
- Adds
gem "rails_site_engine", path: "../..". - Runs
bin/rails generate rails_site_engine:install. - Prunes host boilerplate down to a slim runtime shell and prepares DB.
Profile options:
--site-profile:home-services,software-contracting,portfolio--trade-specialty(home-services only):general,plumbing,carpentry,electrician--business-name: brand/business name for starter content--list-site-profiles: prints available profiles and exits
Interactive behavior:
- If
--site-profileis missing in an interactive shell, the script prompts you. - If
--site-profileis missing in non-interactive mode, the script exits with an actionable error.
Run the generated app:
cd client_projects/acme-plumbing
bin/dev
Move a client project out of client_projects/ into the parent directory when you want to keep it as a standalone app:
bin/move_client_project acme-plumbing
This also rewrites Gemfile to use the engine Git repo (nicho1991/rails_site_engine) after the move.
Default rewritten line:
gem "rails_site_engine", git: "[email protected]:nicho1991/rails_site_engine.git"
client_projects/ is intentionally ignored by git so you can keep many disposable repro apps.
Override the output root with RAILS_SITE_ENGINE_CLIENT_PROJECTS_ROOT=/absolute/path.
Install Generator Contract
bin/rails generate rails_site_engine:install is the single bootstrap step for host apps.
It accepts:
--site-profile=<concrete-profile>--business-name="Your Business"
Concrete profiles:
home-services-generalhome-services-plumbinghome-services-carpentryhome-services-electriciansoftware-contractingportfolio
It is idempotent and ensures:
- site engine host contract (
config/site_engine.yml) - content scaffolding (
content/site.yml,content/pages/*.md, includingcontent/pages/privacy.md) - theme scaffolding (
config/theme.yml) - content contract guide (
content/OVERRIDES.md) - route setup with
LetterOpenerWebbefore engine mount in development - Action Mailer railtie enablement in
config/application.rbfor minimal host apps - local dev mail preview via
letter_opener_web(Gemfile,config/environments/development.rb,/letter_openerroute) - host
bin/devwith PostgreSQL env defaults + Rails server - PostgreSQL env defaults in
config/database.yml
Upgrade note for apps generated before this Action Mailer bootstrap fix:
- Re-run
bin/rails generate rails_site_engine:installin the host app, or manually uncomment/addrequire "action_mailer/railtie"inconfig/application.rb. - Restart the Rails server after updating
config/application.rb.
Upgrade note for apps generated before local mail preview setup:
- Re-run
bin/rails generate rails_site_engine:installin the host app, then runbundle install. - In development, visit
/letter_openerto view delivered contact-form emails.
Upgrade note for apps generated before privacy page scaffolding:
- Re-run
bin/rails generate rails_site_engine:installin the host app to backfillcontent/pages/privacy.md. - If your footer privacy link still uses
href: "/privacy", update it topage: "privacy"incontent/site.yml.
Local Database Defaults
Engine and generated host apps use:
POSTGRES_HOST=127.0.0.1POSTGRES_PORT=54325POSTGRES_USER=postgresPOSTGRES_PASSWORD=postgres
bin/setup, bin/dev, and bin/new_client_project start Docker Postgres when Docker is available.
Tooling Requirements
- Node.js
>=20(required only when maintaining engine CSS/tooling locally)
Dependency Knowledge Baselines
- daisyUI baseline and usage guide:
docs/dependencies/daisyui.md
Host Content Contract
Each host app must provide:
config/site_engine.ymlcontent/site.ymlcontent/pages/<slug>.mdconfig/theme.yml
profile and business_name in config/site_engine.yml are scaffolding inputs for installer-generated files.
Runtime rendering reads content from host files (content/site.yml, content/pages/*.md, config/theme.yml).
Updating Client Sites
When engine structure changes:
- Update this engine.
- In each client app:
bundle update rails_site_engine. - Deploy the client app.
Tests
Run engine tests (dummy harness):
bin/rails test
License
MIT. See MIT-LICENSE.