Skip to content

Latest commit

 

History

History
67 lines (42 loc) · 1.79 KB

Development.md

File metadata and controls

67 lines (42 loc) · 1.79 KB

Development Rails

🚀 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-rails 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.

Console

Enable console history and autocomplete in your ~/.irbrc.

require "irb/completion"
require "irb/ext/save-history"
IRB.conf[:SAVE_HISTORY] = 10000

# and for awesome print
require "awesome_print"
AwesomePrint.irb!

Use Awesome Print or pry-rails for a friendlier console.

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"