This tutorial explains step-by-step how to install Ruby on Rails on a Windows machine.

Before installing of Rails framework, Please make sure that Ruby and Gem are installed Verify ruby is installed using --version option

A:\work>ruby --version
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x64-mingw32]
A:\work>gem --version

Install the Latest or specific Ruby on Rails version on Windows

Once ruby and gem are installed, You can install rails directly.

gem installs command downloads and installs rails and their dependencies.

If you want to install the latest rails, run the below command

gem install rails

It installs the latest version.

A:\work\railsapp>rails --version
Rails 7.0.4

if you want to install a specific version, use the -v option with the version number

gem install rails -v 5.0.1

Here is an example

A:\work>gem install rails
Fetching rack-2.2.4.gem
Fetching crass-1.0.6.gem
Fetching activesupport-7.0.4.gem
Fetching tzinfo-2.0.5.gem
Fetching rack-test-2.0.2.gem
Fetching loofah-2.19.0.gem
Fetching rails-dom-testing-2.0.3.gem
Fetching rails-html-sanitizer-1.4.3.gem
Fetching builder-3.2.4.gem
Fetching erubi-1.11.0.gem
Fetching actionview-7.0.4.gem
Fetching activemodel-7.0.4.gem
Fetching actionpack-7.0.4.gem
Fetching activerecord-7.0.4.gem
Fetching globalid-1.0.0.gem
Fetching activejob-7.0.4.gem
Fetching mini_mime-1.1.2.gem
Fetching mail-2.7.1.gem
Fetching net-protocol-0.1.3.gem
Fetching net-imap-0.3.1.gem
Fetching actionmailer-7.0.4.gem
Fetching nio4r-2.5.8.gem
Fetching websocket-extensions-0.1.5.gem
Fetching websocket-driver-0.7.5.gem
Fetching actioncable-7.0.4.gem
Fetching marcel-1.0.2.gem
Fetching activestorage-7.0.4.gem
Fetching actionmailbox-7.0.4.gem
Fetching actiontext-7.0.4.gem
Fetching thor-1.2.1.gem
Fetching method_source-1.0.0.gem
Fetching zeitwerk-2.6.2.gem
Fetching railties-7.0.4.gem
Fetching rails-7.0.4.gem
Successfully installed tzinfo-2.0.5
Successfully installed activesupport-7.0.4
Successfully installed rack-2.2.4
Successfully installed rack-test-2.0.2
Successfully installed crass-1.0.6
Successfully installed loofah-2.19.0
Successfully installed rails-html-sanitizer-1.4.3
Successfully installed rails-dom-testing-2.0.3
Successfully installed builder-3.2.4
Successfully installed erubi-1.11.0
Successfully installed actionview-7.0.4
Successfully installed actionpack-7.0.4
Successfully installed activemodel-7.0.4
Successfully installed activerecord-7.0.4
Successfully installed globalid-1.0.0
Successfully installed activejob-7.0.4
Successfully installed mini_mime-1.1.2
Successfully installed mail-2.7.1
Successfully installed net-protocol-0.1.3
Successfully installed net-imap-0.3.1
Successfully installed actionmailer-7.0.4
Temporarily enhancing PATH for MSYS/MINGW...
Building native extensions. This could take a while...
Successfully installed nio4r-2.5.8
Successfully installed websocket-extensions-0.1.5
Building native extensions. This could take a while...
Successfully installed websocket-driver-0.7.5
Successfully installed actioncable-7.0.4
Successfully installed marcel-1.0.2
Successfully installed activestorage-7.0.4
Successfully installed actionmailbox-7.0.4
Successfully installed actiontext-7.0.4
Successfully installed thor-1.2.1
Successfully installed method_source-1.0.0
Successfully installed zeitwerk-2.6.2
Successfully installed railties-7.0.4
Successfully installed rails-7.0.4
Parsing documentation for tzinfo-2.0.5
Installing ri documentation for tzinfo-2.0.5
Parsing documentation for activesupport-7.0.4
Installing ri documentation for activesupport-7.0.4
Parsing documentation for rack-2.2.4
Installing ri documentation for rack-2.2.4
Parsing documentation for rack-test-2.0.2
Installing ri documentation for rack-test-2.0.2
Parsing documentation for crass-1.0.6
Installing ri documentation for crass-1.0.6
Parsing documentation for loofah-2.19.0
Installing ri documentation for loofah-2.19.0
Parsing documentation for rails-html-sanitizer-1.4.3
Installing ri documentation for rails-html-sanitizer-1.4.3
Parsing documentation for rails-dom-testing-2.0.3
Installing ri documentation for rails-dom-testing-2.0.3
Parsing documentation for builder-3.2.4
Installing ri documentation for builder-3.2.4
Parsing documentation for erubi-1.11.0
Installing ri documentation for erubi-1.11.0
Parsing documentation for actionview-7.0.4
Installing ri documentation for actionview-7.0.4
Parsing documentation for actionpack-7.0.4
Installing ri documentation for actionpack-7.0.4
Parsing documentation for activemodel-7.0.4
Installing ri documentation for activemodel-7.0.4
Parsing documentation for activerecord-7.0.4
Installing ri documentation for activerecord-7.0.4
Parsing documentation for globalid-1.0.0
Installing ri documentation for globalid-1.0.0
Parsing documentation for activejob-7.0.4
Installing ri documentation for activejob-7.0.4
Parsing documentation for mini_mime-1.1.2
Installing ri documentation for mini_mime-1.1.2
Parsing documentation for mail-2.7.1
Installing ri documentation for mail-2.7.1
Parsing documentation for net-protocol-0.1.3
Installing ri documentation for net-protocol-0.1.3
Parsing documentation for net-imap-0.3.1
Installing ri documentation for net-imap-0.3.1
Parsing documentation for actionmailer-7.0.4
Installing ri documentation for actionmailer-7.0.4
Parsing documentation for nio4r-2.5.8
Installing ri documentation for nio4r-2.5.8
Parsing documentation for websocket-extensions-0.1.5
Installing ri documentation for websocket-extensions-0.1.5
Parsing documentation for websocket-driver-0.7.5
Installing ri documentation for websocket-driver-0.7.5
Parsing documentation for actioncable-7.0.4
Installing ri documentation for actioncable-7.0.4
Parsing documentation for marcel-1.0.2
Installing ri documentation for marcel-1.0.2
Parsing documentation for activestorage-7.0.4
Installing ri documentation for activestorage-7.0.4
Parsing documentation for actionmailbox-7.0.4
Installing ri documentation for actionmailbox-7.0.4
Parsing documentation for actiontext-7.0.4
Installing ri documentation for actiontext-7.0.4
Parsing documentation for thor-1.2.1
Installing ri documentation for thor-1.2.1
Parsing documentation for method_source-1.0.0
Installing ri documentation for method_source-1.0.0
Parsing documentation for zeitwerk-2.6.2
Installing ri documentation for zeitwerk-2.6.2
Parsing documentation for railties-7.0.4
Installing ri documentation for railties-7.0.4
Parsing documentation for rails-7.0.4
Installing ri documentation for rails-7.0.4
Done installing documentation for tzinfo, activesupport, rack, rack-test, crass, loofah, rails-html-sanitizer, rails-dom-testing, builder, erubi, actionview, actionpack, activemodel, activerecord, globalid, activejob, mini_mime, mail, net-protocol, net-imap, actionmailer, nio4r, websocket-extensions, websocket-driver, actioncable, marcel, activestorage, actionmailbox, actiontext, thor, method_source, zeitwerk, railties, rails after 263 seconds
34 gems installed

Next, Check the Rails version installed on the machine using the below command.

rails --version

Next, create an application using the below command

rails new railsapp

change to railsapp directory

cd railsapp

Next, start the Rails application using the Rails server

rails server

It starts the server at the listening 3000 port number.