Installing Ruby and Rails on Windows
September 23, 2010
Updated: January 17, 2016
All of our online courses start with comprehensive instructions for getting the required software installed and set up on your own computer. For the online Rails course, that means installing Ruby and Rails. During the course, you’ll then write, refactor, and test your code directly on your own computer. That way, after the course, you’ll already be familiar with the environment where you can then start writing your own Rails apps!
Setting up a stable Ruby and Rails environment on Windows has never been easier. Here’s our recommended approach…
Install Ruby and Rails
The easiest way we’ve found to install Ruby, Rails, and other supporting
software on Windows is using the RailsInstaller. It’s a self-contained
Windows installer (an
.exe file) that includes a Ruby language
execution environment, a baseline version of Rails, and other useful goodies
such as Git, SQLite, and the Windows DevKit.
On the RailsInstaller page, click the big green "Windows Ruby 2.3" button to download the installer.
Once the executable installer has downloaded, use Windows Explorer to navigate to where you saved the
.exefile and double-click it to start the installation process.
After stepping through a couple standard installer screens, you’ll be prompted for the installation destination. By default, RailsInstaller will be installed in your
C:\RailsInstallerdirectory. We’ll assume you go with the default destination.
When the installation is complete, a command prompt window will open and prompt for your name and email. Then you’ll end up in the
C:\Sitesdirectory. You should see a window with a blinking cursor and a prompt that looks something like this:
If this is the first time you’ve seen this command prompt it may seem rather intimidating, but don’t let it throw you. It’s simply a way to interact with your computer by entering commands. In fact, here comes our first command…
Open a new command prompt by selecting Start -> Run… and typing
cmdinto the dialog box. You should see a new window with a blinking cursor and a prompt that looks something like this:
Verify that Ruby 2.3.3 was successfully installed by typing
Ruby should reply with
ruby 2.3.3p222 (2016-11-22 revision 56859) [i386-mingw32]
Next, update Rails to the latest version by typing
gem update rails
Then sit back and relax as RubyGems downloads all the Rails-related gems and assembles the documentation. After a few minutes, you should end up with a dozen or so gems installed. If you see a warning about "file ‘lib’ not found" while it’s generating documentation, don’t worry about.
Finally, verify that the latest version of Rails was successfully installed by typing
Rails should answer with 5.0.0 or higher.
Create An Example Rails App
Now that we have all the required software installed, let’s create your first Rails app to make sure everything is working in harmony. We’ll create a simple application for managing a list of todos.
From a command prompt, navigate to a directory where you want the application code to live (your
C:\workdirectory, for example).
Start by creating an empty Rails application called
rails new todos
Change into the
todosdirectory that was created in the previous step:
The application doesn’t know about todos yet, so we’ll use scaffolding to quickly generate all the code for managing a list of todos. Run the scaffold generator by typing
rails g scaffold todo name:string due_on:date completed:boolean
You’ll see Rails create a bunch of files, including a migration file for creating a database schema to store todo items in a database (SQLite3 in this case).
Run the database migration by typing
Then start the Rails app by typing
Finally, point your web browser at http://localhost:3000 and you should see a page welcoming you to Rails. To start managing your todos, go to http://localhost:3000/todos.
When you’re done, you can stop the Rails app by typing
CTRL-Cin the command prompt where you started the app.
That’s all there is to it! Now you have everything you need to start building your own Rails apps. And that’s exactly how we recommend you start learning Rails, by actually building something, whether it be for fun or profit.
Ruby and Rails Pro Bundle
If you're ready to dive into developing with Ruby and Rails, there's no better set of courses to put you on a path to success than our popular Ruby and Rails Pro Bundle. You'll come away with a solid understanding of the fundamentals of Rails, and how to put all the pieces together, so you can confidently create your first Rails app or jump right into an existing app!