In this quick post you'll learn how to install Ruby on Rails on a Windows system and run your first Rails app locally.

Note: I'll be using postgeSQL database in this post

Installing Ruby on Rails on Windows is straightforward if you follow the right steps.

I will help you set it up along with essential tools for running your application.

Step 1: Install Ruby Installer First

Visit the Ruby Installer and download the latest version as highlighted in the image.

During installation, ensure you check the box for MSYS2 setup, which allows you to install dependencies easily.

Once installed, verify by typing ruby -v in your command prompt or terminal.

Step 2: Install Rails Now

If Ruby is installed then installing Rails isn't complicated, Rails can be installed using RubyGems, Gem is Ruby's package manager like NPM. Open your terminal again and run:

sh
gem install rails

It'll take some time and after installation, verify by typing rails -v in terminal.

Step 3: Install and setup Database

As Rails is a full stack framework so It works with databases like PostgreSQL or MySQL. Choose based on your project's needs but I'll prefer PostgreSQL.

PostgreSQL

Download it from postgresql.org. Follow the installation steps and remember your credentials like username and password.

MySQL

Get it from MySQL Downloads. Set up a root password during installation and ensure it runs correctly.

Step 4: Install Node.js and Yarn

Rails requires a JavaScript runtime, and Node.js is good enough to handle that need.

Download Node.js from nodejs.org. Once installed, use npm to install Yarn globally by following command:

sh
npm install -g yarn

Step 5: You are Good to Go for Creating your First Rails Application

Now you’re ready to create your Rails app. Open up terminal, Go to your desired folder by using cd command, and then run:

sh
rails new yourappnamehere --database=postgresql

Replace postgresql with mysql if you want MySQL as Database. Enter the app directory by trying cd yourappname and start the server by running rails server command like so:

sh
cd yourappname
rails server

Visit http://localhost:3000 or http://127.0.0.1:3000/ in your browser to confirm your app is running.

And there you go to build something amazing and learn and explore new things.

You can also explore IDEs like VS Code for a smoother development experience. Tools like Git help manage your code.

If you want to learn more I'd highly recommend to check out the Rails Guides Official Document.

Let me know the feedback in comments below. Thanks


Comments(0)