🚀 Best practices for developing with Rails
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.
Use dotenv for environment variables. Do not check this in. Create a .env.example without secrets.
Use Foreman to manage multiple processes.
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.
Use Cacheflow to instrument caches.
Use Letter Opener for email.
Use a tool like pgsync to sync data from another enviroment.
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"