How To Install Rails and Create a New Rails App on a Mac, in 5 Steps!

In my guide to installing Ruby gems on a Mac, I wrote about how hard it is for pretty much anyone new to Ruby to install gems on a Mac, and how my script makes it easy. Even for experienced folks, using a script saves so much time when setting up a new computer. I recently made some new improvements that make it even easier to create a Rails app. Doing everything manually would involve at least 15 steps.

If you haven't run my script since December 22, 2020, or if you installed it for the first time between December 24, 2020 and January 7, 2021, you might have had issues running rails new. With the latest updates, creating a new Rails app only takes 5 steps:

   mkdir ~/testing-rails && cd ~/testing-rails
   chruby 2.7.2
   rails new .

That's it! Once it's done creating the app (it takes a few minutes), you can then run the app:

rails s

and view it in your browser at http://localhost:3000.

To make sure the correct Ruby version is used whenever you cd into your Rails app, add a .ruby-version file:

echo 'ruby-2.7.2' >> .ruby-version

Finally, capture all of these new files in a git commit:

git add .
git commit -m "Create new Rails app with rails new"

Now you can start coding your app, but first read about the first gem you should add to your Rails app.