We're taking a journey, literally. Whip out your map, 'cause your gonna need it. The following is a code prompt, that usually means you need to run a piece of code. Pay careful attention and don't proceed until you've successfully executed the script.
sudo mkdir rails5
cd rails5
git clone https://github.com/rails/rails.git .