Development Rails

July 25, 2025 · View on GitHub

:rocket: Best practices for developing with Rails

Philosophy

Always, always manually test what you’re building in development. It’s extremely important to have a fast feedback loop. Testing on staging or production is slow. If it’s not easy to test in development, spend time to make it easy.

Environment

Use dotenv for environment variables. Do not check this in. Create a .env.example without secrets.

Use Foreman to manage multiple processes.

Debugging

Set up debugging tools behind environment variables so you can enable and disable without changing code.

Use ruby-prof to profile code.

Use Bullet to find n + 1 queries.

Logging

Use Cacheflow to instrument caches.

Email

Use Letter Opener for email.

Data

Use a tool like pgsync to sync data from another enviroment.

Aliases

Use aliases for common commands. Here are a few of my favorites:

# rails
alias rc="bin/rails console"
alias dbm="bin/rails db:migrate"
alias dbr="bin/rails db:rollback"
alias fsw="foreman start -c web=1"

# git
alias gl="git pull -r"
alias gc="git commit"
alias gco="git checkout"
alias gcm="git checkout master"