Getting your Rails Environment Up & Running

Katie Frances
the-coder-grrl
Published in
3 min readApr 11, 2018

First things first, you’ll need to open up your terminal, I use iTerm2, it’s a much better terminal program & it’s very easily customisable with frameworks like Oh My Zsh & Powerline9k, that’s for another post, but it’s not required for this tutorial.

This post is Mac OSX/Linux specific, so I’m not covering Windows here. Before you install Ruby, you may need to update/install extra components for XCode. You can check if you have it installed by running the following command:

xcode-select -p

If you see this:

xcode-select: error: unable to get active developer directory...

You’ll need to install further XCode components, a detailed tutorial of how to do this is here.

Step 1

If you’ve got XCode installed, you’re good to go.

Mac OSX comes with Ruby pre-installed, but we’re going to update it, because most likely your version is out of date. To check the version we type into our console:

ruby -v

The command should return something like:

ruby 2.5.0p0

At the time of writing this, the latest version is 2.5. To update Ruby, you’ll need to type:

curl -L https://get.rvm.io | bash -s stable

You’ll want to update to the latest version of Ruby. You can check the current version here, and update in your command line with the following command:

rvm install ruby-2.5.0

RVM stands for Ruby Version Manager, which means we can specify if we want to use a specific Ruby version. Sometimes you’ll be working on an app with an older version of Ruby and you’ll need to specify this to work on it and not break it.

Once you’ve got XCode & Ruby installed & updated, you’ll need to get your Ruby on Rails developer environment setup.

Now it’s time to get to installing Rails!

Introduction to Rails

Ruby on Rails, or Rails, is a server-side web application framework written in Ruby under the MIT License. Rails is a model–view–controller framework, providing default structures for a database, a web service, and web pages. — Wikipedia

Rails provides a lot of pre-configured stuff, or as my lecturer says “rails gives us this for free/out of the box” which means that you need to write a lot less code because Rails will generate a model, view & controller for you with a single command.

I’d highly recommend learning as much Ruby as you can before starting rails, because it can be extremely overwhelming to dive straight into Rails without knowing it. To be honest, I did this and realised that, one I didn’t know how to fix errors that came up, nor did I know how to customise anything because I didn’t know Ruby nor Rails.

Installation Part 1

Because we have Ruby installed, we can now use a Ruby gem to install Rails. A gem is like a plugin for Rails with little built in features that we can use to enhance our applications. More about gems can be found here.

We’re going to need to install the package manager Homebrew to install Rails first.

Installing Homebrew

In web development you’ll come across Homebrew a lot. It’s a good idea to install it regardless.

We’ll run this command to install it:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Assuming the installation was successful, let’s verify it worked:

brew -v

You should see something like:

Homebrew 1.5.11

For more information about Homebrew, visit their site.

Installation Part 2

To install Rails, we’ll run this command:

gem install rails

You should see something like this:

Done installing documentation for activesupport, actionview, actionpack, activemodel, arel, activerecord, activejob, actionmailer, actioncable, mimemagic, marcel, activestorage, railties, rails after 32 seconds
14 gems installed

If not it’ll give you a big red error. If you get something like that, you’ll need to do a google, or consult the oracle for help.

After you’ve done that, we’re done! That’s it, pretty easy huh?

Just to confirm Rails has successfully installed, we’ll run the following command:

rails -v

You should see something like:

Rails 5.2.0

Yay Rails is installed and ready to go!

Enjoy!

--

--

Katie Frances
the-coder-grrl

I’m a web dev who writes about tech, mental health & coding