How to Set Up Your Rails Development Environment in Cloud9

Thiam Hock Ng
Singapore Rails Learning Group
5 min readJul 10, 2017

The first step before you can develop anything is to set up your development environment.

A development environment consists of:

  • A modern browser, such as Chrome. Most people should already have it.
  • The programming language (e.g. Ruby) and the framework (e.g. Rails installed).
  • The database (e.g. Postgresql) installed.

For this learning group, I am recommending Cloud9. Cloud9 is an online Integrated Development Environment (IDE).

The reason for using Cloud9 is because it is simple to set up.

In a group where different people use different systems, dealing with configuration issues is a nightmare.

So, all the work will be done in Cloud9.

If you want to set up your development environment in your machine, please feel free to do so. You can find some resources at the bottom of this article.

So head over to https://c9.io. Sign up for an account.

Follow through the steps to enter a name, username, and so on.

You will notice that they requested for credit card details. Don’t worry about it. They will not charge you. If you are not comfortable about this, please install the development environment in your local machine.

Then, you will need to set your password.

Creating Workspace

Cloud9 organises project by workspace. You can think of a workspace like a separate computer.

Although it is possible to have more than 1 project per workspace, that’s not my preference due to the limitation of computing power in free Cloud9 account.

Fill in the workspace name and description. Name your project anything you want.

Over at the template section, make sure you select “Blank”.

You may have notice that there is a template for Ruby on Rails and Rails Tutorial. Ignore them for now.

Then click on “Create Workspace”.

Once done, you should see a screen like this.

Your workspace consists of 3 main sections:

  • Directory: This should look familiar to you. This is for you to navigate across different folders and files.
  • Editor: Where you will write your code. The tab system at the top works similarly to Google Chrome’s tabs.
  • Terminal: Where you run your commands (installation, creating rails app, running tests, migrating databases, etc.)

Note: You should type the commands below into terminal.

The default Cloud9 workspace has both Ruby and Postgresql installed. But the Ruby version is outdated. So you will have to first install Ruby by running the following command in the terminal:

rvm install 2.4.1

Then verify that you have the correct ruby installed:

ruby --version

You should get:

ruby 2.4.1p111 (2017–03–22 revision 58053) [x86_64-linux]

Next, you have to install Rails. To do that, type the following command:

gem install rails

Verify that Rails is installed by typing the following command:

rails --version

You should see the version of the Rails (which is 5.1.2 as at the time of writing).

This means that you are done with the installation.

Now, try creating a new Rails app with the following command:

rails new demo

This command tells the computer to create a new Rails app called “demo”. If you want to name your app “sample”, your command will be:

rails new sample

After running rails new demo, you will see a folder is created at your directory — with the name of your app.

Currently, you are viewing the main workspace folder in your terminal.

You can go into another folder from this folder by using the change directory (cd) command. Change directory (cd) into the demo directory by running the command:

cd demo

You will notice that the prompt on the left will change to /workspace/demo — showing the current directory you are in.

Next, you want to see whether your Rails app work. To do that, you have to start your server.

The application is now hosted in this workspace. For local development, you need to manually start the server so that you can access the application.

Start your rails server with the following command:

(For Cloud9 users only)

rails server -b $IP -p $PORT

Click on “Share” at your upper right hand corner. Then click on the Application URL, then “Open”.

You should see this screen.

Congratulations. Now you have your first rails app running.

Note:

For first time users, you might see another screen instead:

An introduction preview before proceeding to your application.

Just click on “Open the App” button. You should be able to see “Yay! You’re on Rails” screen.

To stop your server, head to your terminal screen, then hit CTRL+C to stop.

While there are advantages in using Cloud9, there are also downsides.

First, you will have to go through the installation process for every workspace. This can be quite troublesome if you are developing a lot of apps.

Secondly, you have a limit of your computing power on the free tier. For learning rails, this is not a problem. But if you were to develop a very complicated app, you will face an issue.

If you are serious in learning coding, you should set up the environment in your local machine. You can read more here:

https://www.theodinproject.com/courses/web-development-101/lessons/installations

http://railsapps.github.io/installing-rails.html

--

--