Will Little Subscribe

How to setup a Mac to begin developing Ruby on Rails Web Applications


Last updated: Dec 25, 2020 // Click here to go back to the tutorial series overview page.

Getting your local computer setup for developing web applications is one of the most difficult aspects of learning. In this tutorial, we will go all the way from a generic MacOS install to having a running Ruby on Rails application that you can see in a web browser on your machine. (FYI: If you are on Windows, follow this tutorial instead)

You can work through it with the following video / screencast, or just follow through the steps below and come to the video if you run into problems.

  • Be logged in as an admin user for your computer
  • Make sure you have Chrome installed.
  • Open your “Terminal” application (e.g. cmd+spacebar and type in “Terminal”)
  • (Optional) If you are on a fancy new Mac with the M1 processors, you are going to need to prefix “arch -x86_64” before the “brew” commands below (and the initial command to install brew) to make your computer play nice with software written for the Intel chipsets.
  • e.g. you will copy paste in arch -x86_64 and then add a space and then /bin/b... (use the full line below)
  • Everyone else will be able to use the commands below as-is.
  • Now, let’s install Homebrew (a package manager) and PostgreSQL (database software)
  • /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  • brew install postgres
  • Make sure to follow the copy/paste instructions at the end of the postgres install, specifically to start the database server and ensure it will run when you start your machine next time. This will be:
  • brew services start postgresql
  • Install gpg
  • brew install gpg
  • Install Ruby Version Manager by following these instructions.  Make sure at the end to:
  • source ~/.rvm/scripts/rvm 
  • As of this writing, Ruby 3.0.0 is the latest version, but you should quickly double check and replace 3.0.0 below with the latest version number)
  • rvm install 3.0.0
  • rvm use 3.0.0 --default
  • ruby -v
  • That last command should output “3.0.0” and you’ll be all set.
  • Get Bundler going, which is a gem used to install (“bundle”) other gems from a list of gems in our application:
  • gem update --system
  • gem install bundler
  • Now we’re going to get a code version control program called “Git” setup. The first thing you should do is go register for an account (free) at GitHub.com.
  • In your terminal, enter the following, replacing in your details:
  • git config --global color.ui true
  • git config --global user.name "REPLACE WITH YOUR NAME"
  • git config --global user.email "REPLACE_WITH_YOUR@EMAIL.com"
  • ssh-keygen -t rsa -b 4096 -C "REPLACE_WITH_YOUR@EMAIL.com"
  • (press enter to use defaults and to not set a password)
  • Press enter to accept the default file name, and press enter again to not use a password.
  • Then enter this:
  • cat ~/.ssh/id_rsa.pub
  • Copy that output key and paste it into your GitHub account here.
  • Run the following command in your terminal to ensure it worked:
  • ssh -T git@github.com
  • You’ll see a successful message, and a note about Github not providing shell access (which is fine, you can ignore that).
  • Now let’s get node and yarn installed
  • brew install node yarn
  • Go ahead and install the code editor VSCode, which is a fantastic open source code editor by Microsoft (yes, tons of Mac users actually use a microsoft product).  You can also use another code editor of your choice, of course.
  • Now install the Rails gem (this will take awhile)
  • gem install rails
  • In your terminal, let’s go ahead and make an apps folder and create your rails app:
  • mkdir apps/
  • cd apps/
  • rails new quotesapp -d postgresql
  • cd quotesapp
  • Back in your terminal, run this commands to setup your database
  • rake db:create
  • This connects to PostgreSQL via your current Mac user of the same name, and no password is required so it should automatically work. You should see a message that a couple of databases were created successfully.
  • And finally, let’s spin up your Rails server:
  • rails s
  • You should now be able to open your web browser (use Chrome) and visit http://localhost:3000 and see your new Rails app live.

If you have problems (or see anything above that needs updating), feel free to reach out to me directly at will@wclittle.com. Thanks!

Continue to the next part of the series → Full-stack web development "Hello World" tutorials for entrepreneurs :: Part 1 of 8