Install Rails in Windows machine

  1. Open powershell and check if the ruby is installed in your system by typing the ruby -v command.

If you get the message above, that means you don’t have Ruby installed and you need to install it.

Note: For applications requiring rails 6.x, you need the ruby version above 2.5

2. To install ruby on a windows machine, go to rubyinstaller.org and click on it to download.

3. Once download completes, click on the downloaded file and go through the installation process. Most default installation options (pre-selected) are good. In one of the options you might get the option to download and install the MSYS2 and development toolchain, make sure you have that checked to download and install it.

While installing, when it command prompt pops up, hit enter

After installation is complete, restart the powershell and rerun ruby -v command. It should be showing you the version you installed.

You now have the Ruby programming language installed and working perfectly.

Next Step: Install NodeJS and Yarn

NodeJS is a JavaScript runtime and Rails has this as a dependency in order to work correctly. Yarn is a package manager which Rails (6 and above) uses to manage some assets.

  1. To see if you have node already installed, pull up a PowerShell window and type in node — version followed by enter.

If you get an error message like above, then you will need to install node.

2. To install NodeJS, go to nodejs.org and click on the Download button.

3. Once downloaded, click on the downloaded file and click through the installation options. Leave all the installs to default options.

After installation is complete, restart the powershell and rerun node — version command. It should be showing you the version you installed.

YARN

  1. You can check for an existing installation of Yarn by checking the yarn version in your PowerShell window.

Next step: Install Rails

When we are talking about ruby, the ruby gems play a major role. Rails itself is a rubygem hosted in rubygems.org.

  1. Before we install rails gem, we make sure we install bundler. To install bundler simply type gem install bundler .

note: If you want specific version of bundler, then type gem install bundler -v 1.17.3

2. Next step would be to install webpacker. Webpack is a JavaScript bundler which Rails 6 uses to manage its JavaScript assets. To install webpack, simply type gem install webpacker .

3. Install rails using gem install rails

4 Once successfully installed, you can check for the version of rails that’s installed by typing in the rails -v command followed by enter

Last step: Test

  1. Now that we have rails installed, let’s use it to create a new rails application. You can do it by using the following

rails new test_app

2. You should now be in the test_app folder. This is your newly created rails application.

cd test-app

3. start rails server

rails s

4. Hit localhost:3000 in the browser and you see this result

You have now successfully installed Rails on your windows machine.

Software Developer