Start a new Rails App (v8)

With Tailwind

Is this a new app for a client on Heroku? In addition to these instructions, see these for setting up Heroku.

Create the new app

use these options for:

  • postgres database

  • tailwindcss

  • not using Kamal for deployments

  • skip-ci will skip installing the .github folder, which has a CI deployment workflow

rails new projectname --database=postgresql --css=tailwind --skip-kamal --skip-ci 

If I don't plan on using any of the solid stuff (solid_cache, solid_cable, solid_queue then add --skip-solid

CD to the new app

cd projectname

Create the database

rails db:create

Connect to database in TablePlus app

host: localhost username: briancasel password: emma database_name: Find this in config/database.yml. It's probably projectname_development port: 5432

Create the GitHub repo

Go to https://github.com/new and create a new Repo.

Copy/paste all lines provided there to initialize git and push to this new repo on GitHub

Setup staging & production environments & create credentials

  • Create config/environments/staging.rb and copy all of the contents from production.rb into it.

  • Create credentials by running my terminal aliases:

    • developmentcredentials

    • stagingcredentials

    • productioncredentials

    • testcredentials

Add config for tailwindcss to work

The following must be added to both production.rb and staging.rb in order for tailwindcss to work when deployed anywhere:

# Compress CSS using a preprocessor.
# IMPORTANT FOR TAILWINDCSS: Set this to nil, to ensure assets can compile when deployed.
# Solution found here:  https://github.com/tailwindlabs/tailwindcss/discussions/6738#discussioncomment-2010199
config.assets.css_compressor = nil

Set up background processing

See my notes on using Solid Queue

See my notes on installing SideKiq

Start Rails Server

./bin/dev

The app should now be viewable at http://127.0.0.1:3000

Last updated