Avalanche Effect

Homebrew of polygons, startups, and a dash of coding bits.

Easiest Ruby on Rails New Project Setup

Since RVM will install everything in it’s own directory and repoint your environment to the new installation, you won’t need to worry about prior failed installations of Ruby or Rails. In other words, you don’t need to uninstall everything and attempt a clean install.

On OS X, the key to setting up a Rails project is to use Homebrew to install MySQL and RVM to manage Rails. You’ll be running multiple rubies in seperate terminals concurrently in no time.

1) Install Homebrew with this:

1
$ ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"

2) Install Xcode if you haven’t already. Here’s a good installation article.

3) Install Git with Homebrew:

1
$ brew install git

4) Install RVM:

To get the latest development state:

1
$ \curl -L https://get.rvm.io | bash

If you’ve already installed it, upgrading it:

1
2
3
rvm get head && rvm reload
$ rvm -v
rvm 1.18.21 (master) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]

Don’t forget to do the Post Install Configuration to set up your local shell.

5) Install Ruby 1.9.2-p320 (the latest at this writing) and set it as the default:

1
2
$ rvm install ruby-1.9.2-p320        #Grab a cup of hot tea, it'll take awhile
$ rvm --default use ruby-1.9.2-p320

6) Install Rails:

1
$ gem install rails

7) Install MySQL:

1
$ brew install mysql

Note: After installation, you’ll need to initialize your database. If you skip this, your database won’t work. Type brew info mysql to see the instructions again.

8) Create new Rails app:

I like to create a directory first, generate the Rails app, and then initialize Git inside that directory.

1
2
3
$ mkdir new_rails_app
$ rails new .
$ git init

Done! Now you can check your Ruby and Rails versions specific to that directory and start the Rails server.

1
2
3
$ ruby -v
$ rails -v
$ rails s