Skip to content

atoolz/railway-htmx-ruby-rails8-pg

HTMX + Rails 8 + PostgreSQL Railway Template

Production-ready HTMX starter with Ruby on Rails 8, ERB, and PostgreSQL. One-click deploy to Railway.

Deploy on Railway

License Ruby 3.3 Rails 8 HTMX 2.0.7 PostgreSQL


Deploy and Host HTMX + Rails 8 + PostgreSQL Starter on Railway

Minimal Rails app (no Hotwire Stimulus/Turbo in the UI) using HTMX for todos. Production config/database.yml uses DATABASE_URL. config.hosts is relaxed when RAILS_ALLOWED_HOSTS is blank so Railway hostnames work. docker-entrypoint.sh sets SECRET_KEY_BASE with openssl if unset (fine for demos; set explicitly for multi-instance cookie consistency). GET /health checks the DB.

Dependencies for Hosting

  • Railway PostgreSQL
  • DATABASE_URL = ${{Postgres.DATABASE_URL}}
  • Optional: SECRET_KEY_BASE (bin/rails secret)

Deployment Dependencies


What's Inside

Layer Technology Role
Frontend HTMX + Tailwind (CDN) Partial swaps
Templating ERB Layout + partials
ORM Active Record Todo model

Deploy to Railway

  1. Add PostgreSQL + web service (Dockerfile)
  2. Set DATABASE_URL
  3. Optionally set SECRET_KEY_BASE
  4. Health check: GET /health

Local Development

bundle install
export DATABASE_URL="postgres://user:pass@localhost:5432/htmx_dev"
bin/rails db:migrate
bin/rails s -b 0.0.0.0 -p 8080

Environment Variables

Variable Required Default Description
DATABASE_URL Yes - PostgreSQL URL
SECRET_KEY_BASE No Generated in entrypoint if empty Rails secret
PORT No 8080 Puma/server port

Part of the HTMX Railway Collection

This is one of 15 HTMX starter templates covering different backend stacks, all following the same pattern and ready for Railway deployment:

Stack Status
Bun + Elysia Coming soon
.NET + Razor Coming soon
Elixir + Phoenix Coming soon
Go + Chi Live
Go + Echo Live
Go + Fiber Live
Java + Spring Boot (MySQL) Live
Java + Spring Boot (PostgreSQL) Live
Node + Express Live
Node + Hono Live
PHP + Laravel Live
Python + Django Live
Python + FastAPI Live
Ruby + Rails 8 This repo
Rust + Axum + Askama Live

License

MIT


Built by AToolZ for the HTMX community

About

HTMX + Ruby + Rails 8 + PostgreSQL starter for Railway

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors