skip to content

For a Rails 8.1 greenhouse dashboard on PostgreSQL with Tailwind and no inbound email, which `rails new` flags fit, and what does each change?

level: middleimportance: should knowfreq 50%

answer

  1. three flags, three subsystems
  2. -d postgresql swaps the driver gem
  3. -c tailwind without Node
  4. --skip-action-mailbox, not -M
  5. commented require in application.rb

basics

~10 s

Run rails new greenhouse -d postgresql -c tailwind --skip-action-mailbox: the pg gem and a PostgreSQL database.yml replace SQLite, tailwindcss-rails adds Tailwind without Node, and Action Mailbox's engine is commented out while outgoing mail stays.

solid answer

~40 s

`rails new greenhouse -d postgresql -c tailwind --skip-action-mailbox`. `-d postgresql` puts `gem "pg", "~> 1.1"` in the Gemfile instead of `sqlite3`, writes the PostgreSQL `config/database.yml` (with separate production `cache`, `queue` and `cable` databases for the Solid gems) and adds the PostgreSQL packages to the Dockerfile. `-c tailwind` with the default import maps adds `tailwindcss-rails`, which runs the standalone Tailwind CLI, so no Node or `package.json` appears; with a JS bundler it would go through `cssbundling-rails` instead. `--skip-action-mailbox` makes `config/application.rb` list each framework and comment out `require "action_mailbox/engine"`, so the inbound ingress routes are never mounted, while Action Mailer still sends the alert emails.

code

ruby · 15 lines
ruby
require_relative "boot"

require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
# require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
require "action_cable/engine"
require "rails/test_unit/railtie"

go deeper

for a junior

Recall the three flags and what each one names: -d postgresql for the database, -c tailwind for CSS, --skip-action-mailbox for inbound mail.

for a middle

Explain the side effects: the pg gem and the multi-database production config, tailwindcss-rails versus cssbundling-rails, and the commented engine require that unmounts the ingress routes.

for a senior

Show judgement about what to skip: inbound email is safe to drop, Active Storage is not if photos may come, and every skipped framework is one fewer route set and boot cost.

for a principal

Frame generator flags as a team standard: decide whether a .railsrc preset or a maintained template is worth it, and who owns keeping it current.

## The command A greenhouse dashboard that stores sensor readings in PostgreSQL, styles its pages with Tailwind and never receives email needs three flags on top of the defaults: ```bash rails new greenhouse -d postgresql -c tailwind --skip-action-mailbox ``` Each flag touches a different part of the generated app, and each has a neighbour that is easy to confuse with it. ## `-d postgresql`: the database driver and its config `--database` (short form `-d`) chooses the Active Record adapter the app is preconfigured for. With `postgresql`: - the Gemfile gets **`gem "pg", "~> 1.1"`** in place of `gem "sqlite3", ">= 2.1"`; - `config/database.yml` is written from the PostgreSQL template: `adapter: postgresql`, `encoding: unicode`, `max_connections` read from `RAILS_MAX_THREADS` (falling back to 5), and databases named `greenhouse_development` and `greenhouse_test`; - because the Solid gems are on, **production is a multi-database block**: `primary`, plus `cache`, `queue` and `cable` databases, each with its own `migrations_paths` such as `db/queue_migrate`; - the production `Dockerfile` gets the PostgreSQL client package at runtime and `libpq-dev` in the build stage, so the `pg` gem compiles. ## `-c tailwind`: which gem depends on the JavaScript choice `--css` (short form `-c`) has no default, so Tailwind only appears when asked for. Which gem arrives depends on whether the app has a JavaScript runtime: | JavaScript choice | `-c tailwind` installs | Node needed? | |---|---|---| | default `importmap` | `tailwindcss-rails` | no | | `-j esbuild`, `rollup`, `webpack` or `bun` | `cssbundling-rails` | yes (or Bun) | With import maps, `rails new` runs `tailwindcss:install` after bundling. That writes the Tailwind entry file at `app/assets/tailwind/application.css`, builds into `app/assets/builds`, and adds a watcher process for development. The standalone CLI comes from the `tailwindcss-ruby` gem, so the sensor dashboard stays free of a `package.json`. ## `--skip-action-mailbox`: inbound mail only **Action Mailbox** routes *incoming* email to mailbox classes. **Action Mailer** *sends* email. The dashboard has no inbound mail, but it may well send frost alerts, so the right flag is `--skip-action-mailbox`, not `--skip-action-mailer` (`-M`). What it changes: 1. `config/application.rb` stops using `require "rails/all"` and lists each framework's railtie, with `# require "action_mailbox/engine"` commented out. 2. Because the engine is never loaded, its ingress routes under `/rails/action_mailbox/...` (Postmark, Mailgun, SendGrid, Mandrill, relay) and the conductor pages are not mounted, which removes endpoints the app would never use. 3. Everything else stays: Action Mailer, Active Storage and Action Text are untouched. The implication runs one way only: `--skip-active-storage` implies `--skip-action-mailbox` and `--skip-action-text`, because both store attachments, but skipping Mailbox implies nothing. Reaching for `--skip-active-storage` to drop inbound email would also lose uploads, which a dashboard with plant photos might want. ## Making the choices stick These three flags are easy to forget on the next app. Two generator features carry them: - **`~/.railsrc`** (or `$XDG_CONFIG_HOME/rails/railsrc` when that file exists) holds default arguments that `rails new` inserts on every run; `--no-rc` ignores it and `--rc=PATH` points at another file. - **`-m` / `--template`** applies an application template, a local path or a URL, before `bundle install` runs. Both are ways to encode a team's stack once instead of trusting memory. ## Checking the result and the usual mistakes After generation, three quick checks confirm the flags did what you meant: the Gemfile lists `pg` and `tailwindcss-rails` and no `sqlite3`; `config/application.rb` shows the commented Mailbox line; and `config/database.yml` names `greenhouse_development`. The mistakes interviewers listen for: 1. Passing `-M` (`--skip-action-mailer`) to drop inbound email, which also removes the mailer the frost alerts need. 2. Passing `--skip-active-storage` for the same purpose, which drops uploads and Action Text with it. 3. Forgetting `-d` and planning to "switch later": possible, but it means rewriting `database.yml`, the Gemfile and the Dockerfile packages by hand or with a converter, so it is cheaper to choose at generation time.

  • What changes if the dashboard also needs `-j esbuild` for a charting library?
    With a JavaScript runtime in play, `-c tailwind` no longer installs `tailwindcss-rails`. The generator adds `cssbundling-rails` and runs `css:install:tailwind`, so Tailwind builds through a `package.json` and Node. The JavaScript side switches from `importmap-rails` to `jsbundling-rails`. The app now needs Node in development and in the Docker build.
  • How would a team make `-d postgresql -c tailwind` its default for every new app?
    Put the flags in `~/.railsrc`; `rails new` reads it and inserts those arguments on every run, and `--no-rc` skips it for a one-off. For more than flags, keep an application template and pass it with `-m`, a path or URL that is applied before `bundle install`.

  • --skip-action-mailbox also stops the app from sending email.
  • --css tailwind always brings in Node and a package.json.
  • Use --skip-active-storage to drop inbound email; it is the narrower flag.
  • Switching to PostgreSQL leaves the sqlite3 gem in the Gemfile beside pg.
  • Skipping Action Mailbox deletes its migrations from db/migrate.