Introduction to Rails Installation on Windows
Today we are going to learn about how to install Rails on our local machine. So this is like a Rails—to install Rails on your machine it has like a few dependencies. So basically, we are going to cover each dependency, how we can install the dependency so that our Rails application works perfectly fine on our machine. So what we can do, so we can first, what we can do, we can just open a few links. So basically, we will start with one link at a time.
Installing Node.js Dependency
So let's open this link. Now, this is the node.js official website. You can move to this website and download this installer, and this is the LTS version. You can download the Long Term Support version, so LTS version, and you can install node.js on your machine.
So when you have installed node.js on your machine, then this would help you to install the npm package. Okay. So when you have installed node.js, so you can run this command on your machine: node --version, and this will help you get started with that.
So I'll give you a quick hint. When I've opened the command prompt, I will type node --version. So here you can see the node has been installed on my machine, so it looks perfectly fine. Okay. So yeah. So then you can, then you have installed Node.js on your machine.
Installing Yarn Package Manager
Then what you can do, you can move to the another link. This is how to install Yarn. The Yarn is another dependency required to install Rails on your machine. So when you have installed node.js, you would have access to npm package.
So you can run this command: npm install --global yarn. Or the alternative way is to click on this and click on Operating System: Windows, classic stable version, and you can download the installer. So when you have downloaded the installer, so you can install Yarn. As you will get a setup, you will have an MSI installer, and you will, this will give you a MSI file that will walk you through installing Yarn on Windows. So basically, it will give you a setup which will help you installing Yarn on your machine.
So this is one of the methods to install Yarn on your machine. So basically, now you have covered the two parts. So basically, you have installed node.js and Yarn. And you can install with by npm also. So you can install with npm and you can run this command. And to check if this is installed, then you have to type yarn --version. Okay, so here you can see you have got two things: one is Node and another is Yarn.
Setting Up the SQLite3 Database
So next, moving to the third part, you can move to SQLite website. So this is the third dependency. And when you click on this link, so you can access to this. So this is, now you move to this pre-compiled binaries for Windows. Now you have to choose either of one of them, either 32-bit or 64-bit. Okay, choose according to your system: 32-bit or 64-bit. So this is required, either 32-bit or 64-bit. Install any one of them.
So, depending on your system, then this one is mandatory. So what you'll get, you get two files in this and two files in this and three files in this. So since this one is compulsory, this will be three files and either one of them will be 3 plus 2, that is five files. You have to extract all the five files and copy them and paste them into your C:\Windows\System32, okay?
Then when you install, copy and paste them inside in the C:\Windows\System32, then your SQLite is perfectly installed. And you can type sqlite3 --version. Okay, so this would help install SQLite on your machine. So here, it's good to go. Yeah, nice.
Installing Ruby and Key Gems
Now what you need to do, the now moving to the fourth part, you need to move to RubyInstaller website. So basically, RubyInstaller is intended to install Ruby on your Windows machine. Okay, so basically you have Ruby and you can click on download button, and this will give you a list from where you can choose from which Ruby version you have to download and install. I would recommend you to download this latest version and then you can walk through if you have followed in previous tutorials. So you must have already followed this step to install Ruby on your machine.
Okay, so this is the fifth part. Now to access, to check whether Ruby is installed, you need to type ruby --version. You have Ruby. Now Ruby by default installs the gem package manager. So gem --version. So 3.2.3 is also installed.
So now you have to execute two commands. One is gem install sqlite3. Okay? Then gem install sqlite3 would install sqlite on your machine. And there's something like this you need to type. Okay and yeah, so this is, this step is needed. And another one is this, you have to run this command: gem install rails. So after running these two commands, then you have installed Rails on your machine successfully. But this one is the most important command: gem install rails. Okay? So after that, you have to type rails --version. Then you have Rails on your machine. So the latest version of the Rails is 6.1.3.1. So then you have installed Rails on your machine.
Creating a New Rails Project
So I walked you through the part how you can install Rails on your machine. Then simply you can move to, see, you can move to Desktop. I can move to Desktop and I will do rails new and basically this is your project name. Okay, so you can type any project name. I can type rails my_project and here you can see that now it will start creating a Rails project on your machine. And bundle install is installing all the dependencies required for your project. So basically this would show you how to install dependencies for your project. And when this process is successful, then you are able to run the Rails application on your machine. Okay, so this would take a little time.
Quick Dive into MVC & Server Commands
So you can, so basically then I can walk you through a few commands. So basically, Rails... I'll give a quick overview. Rails is an MVC architecture. So MVC, M stands for Model, V stands for View, and C stands for Controller. Okay, so Models is like basically working with your database. And then you have View, then like View is like presentation on front-end, presentation layer. And Controller is like communicating logic and communication, and then you can see linking the above two.
Okay, so this is like MVC architecture followed in Rails. So here you can see it's installing the Rails or it's like a project on your machine. Then you can type the command... so basically there are two commands. One is rails new project_name and you can then type rails server. Okay, so by default it will start the server on your local machine. Okay, so I hope it's good to go. Then the Rails server will be started on your local machine. So this is how the process will go. And then you, like this is follower... so we can wait for this process to complete. Then I think we can start the Rails server on our machine.
Launching and Verifying the Rails Server
So hey everyone, welcome back. So like, now this has been installed. The Rails project has been initialized in our directory. So basically, we can... I was here: C:\Users\Personal\Desktop. I had created the Rails project here. Now I can move inside my project by cd my_project and I can simply type rails server. And here you can see now the Rails server will start on my localhost. And at the same point, you can move to the project, inside the same project directory, and you type code . so this would open VS Code. So basically this is the Gemfile. There are like various things here, so we will go over through it.
So the Rails server has been started on my machine. So now you can type localhost:3000 and you can see the Rails server runs perfectly fine on my machine. So this is the Rails... now this is how you can access Rails server on your machine. And at the same time, you can see that I made a GET request for the same. So you can track the server here. So from next, we will start with some basics of Rails. So thank you for watching this tutorial. Thank you everyone.