Chapter 2: Installing Ruby and Rails

Chapter 2: Installing Ruby and Rails

AI Reading

Quick summary of this article

This chapter explains how to set up Ruby on Rails on your computer. The process involves installing Ruby first, then using Ruby's gem command to install Rails, and finally verifying the installation with version-check commands. Installation methods differ slightly by operating system, but the core steps are the same.

  • On Windows, download and run RubyInstaller from the official Ruby website and accept the default options.
  • On macOS or Linux, use a version manager like RVM or rbenv to install Ruby (e.g., Ruby 3.3.0) and easily switch between versions.
  • Install Rails by running gem install rails in the terminal, which also installs all dependencies and may take a few minutes.
  • Verify the installation by running rails --version (expect Rails 7.1.x or newer), ruby --version, and sqlite3 --version to confirm the default database is available.
  • Once rails --version prints a version number, your environment is ready to create a first Rails application.

Chapter 2: Installing Ruby and Rails

Before you can build Rails applications, you need Ruby and Rails installed on your computer. The installation steps are slightly different on Windows, macOS, and Linux, but the core idea is the same: install Ruby first, then install Rails as a gem.

In this chapter, you will install Ruby and Rails, and verify the installation with a few simple commands.

🖥️ Installing Ruby

On Windows, download and run RubyInstaller from the official Ruby website and accept the default options. On macOS or Linux, the easiest way is to use a version manager such as RVM or rbenv so you can switch Ruby versions easily.

# macOS / Linux (using rbenv)
brew install rbenv ruby-build
rbenv install 3.3.0
rbenv global 3.3.0

# Check the Ruby version
ruby --version

🚀 Installing Rails

Once Ruby is installed, open your terminal and install Rails with the Ruby gem command:

gem install rails

This installs Rails and all of its dependencies. Depending on your internet speed this may take a few minutes.

✅ Verifying the Installation

After the installation finishes, check the version to confirm everything is working:

rails --version

You should see a message such as Rails 7.1.x or newer. You can also check that Ruby and SQLite (the default database) are available:

ruby --version
sqlite3 --version

🏠 Practice Exercises

# 1. Check your Ruby version
ruby --version

# 2. Install Rails (if not already installed)
gem install rails

# 3. Confirm Rails is ready
rails --version

When rails --version prints a version number, you are ready to create your first Rails application in the next chapter.

Leave a Reply

Your email address will not be published. Required fields are marked *