Active::Rails: Starting Your Rails Journey (Windows)

RICHARD IGBIRIKI
4 min readJan 23, 2019
Photo by Paul Jarvis on Unsplash

Hey guys! Ruby on Rails is one of my favorite Frameworks for web development cause of its simplicity, efficiency, and ease of use. Building with Rails is awesome! But setting it up on Windows computer can be a bit of a drag. So, to kick off what may be a series on developing with Rails, I will like to quickly go over how to set up your environment on a Windows OS.

To facilitate the process, I have gathered all file links below.

Installation files

Installation Files

  1. Git: For version control, and collaboration
  2. Node and Yarn: For dependencies (other required installations needed later on)
  3. RubyInstaller: Ruby language installer (Download with Devkit)
  4. XAMPP: Mysql Database and Apache server

Ruby Installation

Open the RubyInstaller file for installation. On Completion, a command line as shown below will pop up.

Ruby components

When prompted to select what components to install for Ruby, Enter 3.

When this is complete, run “ruby -v” to see what version of Ruby has been installed.

Ruby Version

To update all Ruby Gems, run “gem update” inside your project folder.

To install rails gem, run “gem install rails”

To install bundler gem, run “gem install bundler”

To install mysql2 gem, run “gem install mysql2 — -plaform=ruby”

To confirm installation, run “rails -v” for rails version.

Congratulations, you have successfully installed Ruby, and Ruby on Rails.

Other Installations

Open, and follow the instructions to install the other required files.

Starting a Rails Project

We have successfully installed Rails, and Xampp (Mysql), it is time to create our amazing app using Rails.

To create a new rails app “rails new <app_name>”

Replace app_name with the name of your app. In this tutorial, our awesome app will be demoApp.

Create a new rails app

Yay! If this runs correctly, then our set up was successful. Using your favorite text editor (atom or code), open your project.

Replace “gem sqlite3” with “gem ‘mysql2’, ‘~>0.5.2’” in your Gemfile as shown below

Add mysql2 gem to Gemfile

Update your database.yml under config/database.yml as shown below

Database.yml Configuration

To create matching user details for your mysql database, open xampp control and click on Admin besides Mysql. See below.

Xampp control

This will redirect you to your phpmyadmin dashboard. Click on user accounts to create a new user matching the information on your database.yml. See below.

Create a database user matching info on database.yml

Finally, to create our databases, in your command line, navigate to your project directory, and run these commands to install our version of mysql2 and set up the database for our project.

“bundle install”

“rails db:setup”

Create databases

To start our rails project, run

“rails s” or “rails server”

Hurray!!! Our app runs, and we see this:

codename: Llamas in Pjamas

To view our project listening on port 3000 we visit

localhost:3000

on our favorite browser.

Rails! We are Live!

Congratulations

We have successfully installed all the requirements for our environment, and have built our first Rails application. Not like it does anything spectacular :) but it is awesome!

Conclusion

Rails is great for web development, however, its installation and setup can be painstaking…especially if you are in a windows environment. I hope this tutorial helps you with no hiccups along the way, but if you encounter any issues just google it :). Any errors involving psych, uninstall it and reinstall the default version by running

“gem uninstall psych” and “gem install psych -v 2.0.1”.

This is my first tutorial, so I hope it makes it easier for everyone trying to install Rails for the first time.

Sign up to discover human stories that deepen your understanding of the world.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

RICHARD IGBIRIKI
RICHARD IGBIRIKI

Written by RICHARD IGBIRIKI

Software Developer. Writes about Javascript, Rails, and tech culture.

No responses yet

Write a response