Will Little Subscribe

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

Last updated: September 3, 2020

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)

  • Be logged in as an admin user for your computer
  • Make sure you have XCode, Git, and Chrome installed. Use those links if you don’t yet have them installed.
  • Open your “Terminal” application
  • 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.
  • Install gpg
  • brew install gpg
  • Install rvm (as of this writing, Ruby 2.7.1 is the latest version, but you should quickly double check and replace 2.7.1 below with the latest version number)
  • gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
  • curl -sSL https://get.rvm.io | bash -s stable
  • source ~/.rvm/scripts/rvm
  • rvm install 2.7.1
  • rvm use 2.7.1 --default
  • ruby -v
  • Get Bundler going
  • gem update --system
  • gem install bundler
  • Now let’s get node and yarn installed
  • brew install yarn
  • brew install node
  • 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, 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 https://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!