Rails: Install Rails 4.2.3 with rbenv


It seems that the community is split between whether they should use rvm or rbenv to manage different versions of Ruby and Rails.

I decided to give them both a try and found more success with rbenv. In the end, they're both very similar but rbenv seemed a little more straight forward.

If you'd prefer to read more about the matter before proceeding, I suggest reading this and this.

You might even want to learn a little about bundler.

If you know that you'd rather use rvm instead, here is my tutorial on how to do it.

Here's my article on how to install Ruby and Rails using Mac, Homebrew, and Ruby Version Manager.

Step 0 - Install homebrew

Homebrew is a package manager for stuff other than Ruby or Rails. You'll need this to install rbenv.

Install Homebrew

Step 1 - Install rbenv

Install rbenv

brew install rbenv

Step 2 - Install Ruby

Install ruby

brew install ruby-build

Configure your environmental ~/.bash_profile by pasting this single line of code into Terminal.

echo 'eval "$(rbenv init -)"' >> ~/.bash_profile

Refresh your terminal. This is the same as restarting terminal.

source ~/.bash_profile 

Double check that rbenv has been installed.

which rbenv

Double check your installation of rbenv

Standing on the shoulders of giants

Install whichever ruby version you need. One trick is to look at what version Heroku supports and just copy them.

rbenv install 2.x.x

Every time you install something, you need to rehash

rbenv rehash

Switch your computer to start using Ruby 2.x.x

rbenv global 2.x.x

Step 3 - Update gem

If you're on Mac OS X, you simply need to update gem.

gem update --system

Step 4 - Install bundler gem

Bundler was added to Rails 3 to manage gems.

gem install bundler

Remember that every time you install something, you need to rehash it.

rbenv rehash

Step 5 - Install rails

Install Rails and skip the documentation in order to speed up the install. If you're not sure which version of Rails to pick, try looking at Heroku's package or OpenShift's cartridge

gem install rails --version 4.2.3 --no-ri --no-rdoc
rbenv rehash

Step 6 - Install a database

Install a database using Homebrew

Step 7 - Pick an IDE

  • Textmate is lightweight, capable of handling ruby, rails, javascript, html, erb, jade and pretty much anything else you throw at it.
  • RubyMine is awesome if you're familiar with IntelliJ or PyCharm. brew cask install rubymine
  • RadRails is good for developers familiar with Eclipse.