SaaS bootstrap in Rails: the template I use
Every time I start a new SaaS in Rails, I end up spending 30 minutes remembering the same flags. This post is my cheat sheet.
The evolution of my rails new
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# v1
rails new app --database=postgresql
# v2
rails new app --database=postgresql --webpack=react
# v3 (API only)
rails new api --database=postgresql --skip-javascript --skip-turbolinks --skip-sprockets --skip-action-text --skip-webpack-install
# v4 (current)
rails new app -d postgresql \
--skip-action-mailbox \
--skip-action-text \
--skip-spring \
--webpack=react \
-T \
--skip-turbolinks
v4 is my current default: PostgreSQL, React via Webpacker, without Action Text/Mailbox/Spring/Turbolinks, without a default test framework (-T) — I prefer setting up RSpec afterward.
Database setup
rails db:create does the job, but it’s worth checking config/database.yml to adjust host/user before anything else.
GraphQL with GraphiQL setup
1
rails generate graphql:install --relay --batch
For GraphiQL to work with the modern Rails stack (without Sprockets by default), there are two adjustments:
In config/application.rb, uncomment/add:
1
require "sprockets/railtie"
And in app/assets/config/manifest.js, add:
1
2
//= link graphiql/rails/application.css
//= link graphiql/rails/application.js
Without this, the GraphiQL interface has no CSS/JS and becomes just a bare form.
Next steps in the template
- Devise setup for authentication
- Docker setup (
Dockerfile+docker-compose.ymlfor Rails + Postgres + Redis) - Working login flow end to end
Those three I cover in separate posts — each one becomes a small tutorial.