Guide to Using C9.io for Your Rails Environment
This guide will walk through how to use the Bottega Devcamp Rails development environment on C9.
Guide Tasks
  • Read Tutorial
  • Watch Guide Video
Video locked
This video is viewable to users with a Bottega Bootcamp license

If you're not on a Linux machine or Mac, a good option is to use C9. As I've mentioned before, Ruby and Rails don't work well on other operating systems like Windows. Cloud9 or C9 is a powerful browser-based development environment that has all kinds of different programming environments.

While C9 is a good tool, it's also it does take a bit of time to get set up.

Go to https://c9.io and sign up for a free account.

You can choose to go through the full set of tutorials in the website. However, this option is going to take quite a bit of work.

Sign-up for an account and Join our Team

Alternately, sign up for an account and send me your email address or username. I'll add you to the Bottega Devcamp team, so you can go through the files I've uploaded. It will contain different settings that you can use to set up your own account. In fact, you'll be able to use these settings not just for this project, but for your other Rails projects as well.

Once you send me your information and you are added to the team, you should get an email from the Team bottegadevcamp.

You'll see a link to C9.io. Click on this link, and you'll be prompted to enter your details like your name, username, the kind of developer you are (student), and how you will use Cloud9 (coursework). Confirm these details, and you'll be asked to solve a puzzle or enter some phrases to make sure you're not a robot. Then click create account.

Don't forget to set your password for extra security.

Creating a Workspace

Now, you can create your own workspace, but what I want you to do is take advantage of the workspace I've already created.

To do that, click on "Create a workspace", and in the next page, choose a tab called "Clone workspace"

large

Give a name for your workspace. Next, go to the dropdown menu called "Clone workspace", and you'll see some options.

Choose the "devcamp/rails-workspace" choice. Finally click on the button called "Create workspace".

This process can take a few minutes, depending on your machine and Internet speeds. Essentially, what it is doing is copying all the configuration files, and the virtual machine that is configured for you as well.

Once the process is done, you should see this screen.

large

Now you will see the dashboard and a little welcome screen. This is the README file. It contains some basic things that you can reference as we go through the instructions.

Ruby 2.4.0 is already installed as well as Rails.

What is the Bash?

Click on the tab called "bash". This is the bash shell. This is where you'll be running all your commands. This essentially works just like the terminal, you're just accessing a Linux Shell. Therefore, you can follow along with the rest of the course as if you were on a Mac. Type the command: rvm list to make sure you have the right version of Ruby. You should see "2.4.0"

Postgres Database

Now that we have C9 setup, we need to do a few other things. First, we'll start the postgres database. To do that, you can go to your README file, copy the command to startup the Postgres database, paste it in your bash shell and hit ENTER.

The command is: sudo service postgresql start.

This will start the postgres server.

Creating a Rails App

Next, we'll create a Rails app. You can do that by copying and pasting the code from README file.

The command is: rails new MyApp -T --database=postgresql

In this command, you're asking the system to create a new app called "MyApp" without the test environment, which is what -T stands for. With the last section of the command you're asking the app to set your database as postgresql.

This should generate your rails application.

Once this is complete, us the command: cd MyApp/ to move into your app directory.

Create Database

Next we need to create our database. The command for that is : rails db:create

Rails Server

Finally, you need to run the Rails server. You will find the code in the README file: rails s -b $IP -p $PORT

This is slightly different from how you would run the server from a local Mac machine or Linux because in this case, you're running it on the Internet with your cloud based IDE.

Next click on Preview < Running Application and you should see your rails app running on the right hand side of your screen. Congratulations! You have rails installed and you have generated your first Rails app.

large

With this set up, you should be able to follow along with me on this course.