Matthew Lindfield Seager

Matthew Lindfield Seager

New Rails App Checklist

I run up a new Rails app often enough that I have a certain way I like to do things, but infrequently enough that I normally have to spend a bit of time on Google/Stack Overflow remembering how to do it that way. This checklist is my attempt to remedy that.

Latest Ruby Version

If I’m starting a new project I want to be starting with the latest (usually stable) ruby.

  • Ensure rbenv up to date: brew upgrade rbenv ruby-build
  • Check what the latest stable version is: rbenv install -l
    • 2.5.1
    • 2.5.2
    • 2.5.3 <- the highest one before dev/preview
    • 2.6.0-dev
    • 2.6.0-preview1
    • 2.6.0-preview2
    • 2.6.0-preview3
    • jruby-1.5.6
  • Install it (will prompt if already installed): rbenv install 2.5.3
  • Set it as global version (probably): rbenv global 2.5.3

Latest Rails Version

I also want it to be on the latest (again, stable) Rails.

  • Check latest version of rails: gem list rails --remote -e --all (-e for exact match, –all shows all versions, not just the latest… is optional)
    • rails (5.2.1, 5.2.0, 5.1.6, 5.1.5, 5.1.4, 5.1.3….
  • Install that version: gem install rails -v 5.2.1
  • Instead of the above two steps I can probably just use bundler conventions:
    • gem install rails to get latest
    • gem install rails -v '~> 5.0 to get latest 5.x.y version

Rails New

My philosophy (as a relative newbie) is to pretty much use Rails “The Rails Way” (the Basecamp way?). At this stage that means I don’t monkey with the default gems (with one exception), I just use the default test framework, javascript framework, etc initially. I do change my dev database to Postgres however.

  • Create new rails app without running bundle (about to modify it anyway) and with Postgres as database: rails new --skip-bundle --database=postgresql <app-name>
  • My one exception to default gems is switching to HAML which I like writing (and reading) so much more than ERB: add “gem ‘haml-rails’” to Gemfile
  • Run bundle
  • Convert the three default erb templates (application, html mailer and text mailer) to haml and choose yes when it asks if you want to delete the originals: rails haml:erb2haml

Setup Version Control

I use Github mainly due to inertia/convenience. I have tried Bitbucket, and like being able to hide my work in private repositories for free, but it’s probably good for me to develop “in the open” a bit more.

  • Create repository on github.com
  • git add .
  • git commit:
    • Initial commit
    • - Latest ruby
    • - Latest rails
    • - HAML instead of ERB
  • git remote add origin git@github.com:<user>/<repo-name>.git
  • git push -u origin master

And then?

Next steps should probably be along the lines of (not necessarily in this order):

  • Update the README so others (probably just future me) know what to do to get started
  • Add any additional steps to bin/setup?
  • Deploy to Heroku - for speed, convenience and cost (free while experimenting)
  • Start writing code

Possible Future Process Improvements

These are some things I might want to think about enhancing next time I use this checklist (or review this process).

  • Come up with a README template to reduce friction and make me more likely to get off to a good start
  • Maybe come up with a rails new template (passed in with -m)… or “specify extra command-line arguments to be used every time ‘rails new’ runs in the .railsrc configuration file in [my] home directory”
  • Not having to go to GitHub.com to create repository, the following command seems to work if using a personal access token with “public_repo” scope: curl -H "Authorization: token 12d3fd45f6ac7c89012345678db901ac2a3456f7" '[api.github.com/user/repo...](https://api.github.com/user/repos') -d '{"name":"test-repo"}'
  • Add heroku instructions/notes