Setup Ruby On Rails on MacOS

This will take about 30 minutes.

Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. There are plenty of people who have documented solutions for them.

First, we need to install Homebrew. Homebrew allows us to install and compile software packages easily from source. Homebrew comes with a very simple install script. When it asks you to install XCode CommandLine Tools, say yes. Open Terminal and run the following command:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Next we're going to be installing Ruby using one of three methods. Each have their own benefits, most people prefer using rbenv these days, but if you're familiar with rvm you can follow those steps as well. I've included instructions for installing from source as well, but in general, you'll want to choose either rbenv or rvm.

Choose one method. Some of these conflict with each other, so choose the one that sounds the most interesting to you, or go with my suggestion, rbenv.

Now that we have Homebrew installed, we can use it to install Ruby. We're going to use rbenv to install and manage our Ruby versions. To do this, run the following commands in your Terminal:

brew install rbenv ruby-build

              # Add rbenv to bash so that it loads every time you open a terminal
              echo 'if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi' >> ~/.bash_profile
              source ~/.bash_profile

              # Install Ruby
              rbenv install 2.3.1
              rbenv global 2.3.1
              ruby -v
gem install rails --version 5.0.0

If you're using rbenv, you'll need to run the following command to make the rails executable available:

rbenv rehash

Now that you've installed Rails, you can run the rails -v command to make sure you have everything installed correctly:

rails -v 
# Rails 5.0.0

If you get a different result for some reason, it means your environment may not be setup properly.