Ruby on Rails with Ubuntu – A #DevMov Challenge

Developer Movement – New #DevMov Challenges

A new set of #DevMov challenges are out. You have from Feb 16th through March 15th, 2015 to complete them. Today I will be discussing how to complete the Ruby On Rails challenge. You can see all the challenges over at

If you have not heard, Developer Movement allows people to get active and motivated to learn coding. You receive points for completing challenges and can use those points for awesome such as, a new Surface Pro 3.

#DevMov Challenge – Ruby on Rails

The description for this challenge reads:

Create a simple Ruby on Rails web app on an Azure virtual machine. Read this tutorial for some helpful tips.
Submission Criteria: Upload a screenshot that clearly shows your virtual machine instance in the Azure portal (make sure we can see the running status and DNS name), and the corresponding web app running in your browser window.

Sounds simple enough, right? I went ahead and followed the tutorial the challenge mentions, and it was missing a few things so I decided to help people out with the missing steps.


In order to complete the task at hand:

  • You must have an Azure account. If you don’t have one, don’t worry, you can try a free trial.
  • You must start a VM (Virtual Machine)
  • You must install the Ruby On Rails packages and dependencies
  • You must create your simple web app
  • You must celebrate learning something new

Creating a Virtual Machine

Once you have an Azure account, creating a Virtual Machine is quite simple.

Firstly, sign into your azure account. Once inside, you will see a new button on the bottom left of the screen, press that.


The New button is used to make a Virtual Machine, website, and various other objects

The New button is used to make a Virtual Machine, website, and various other objects


After selecting the New button, Press commute, Virtual Machine, and quick create. You will need to type a name for your Virtual machine. For my Virtual Machine, and to follow these steps, choose the Ubuntu (in this case, version 14.10). To keep cost down, I selected the most basic Virtual Machine. If you are on a trial, you don’t need to worry about costs too much. Type a password, you will use this to sign into your Virtual Machine. Below is a screenshot of my sample settings:

Virtual Machine Settings

Virtual Machine Settings

Once you create the VM, you will see a screen explaining the status of the creation. Once everything is done, you will see a screen similar to this:

VM Started

VM Started


Now it is time to sign into the server and install your packages. You will need to use a program to do this, in my case I used the free program PuTTy. You will need to enter the server name you entered when you created the VM. Once entered, you need to press open.

Putty Login

Putty Login

You will see a command prompt window appear, asking for your username and password. The username should be azureuser and the password is whatever you chose when creating the VM. When typing in the password, you might not see your cursor move. This is normal. Once you type your password, press enter.

Enter your username and password

Enter your username and password

Now to enter a series of commands to install the required packages.

First, enter:

sudo apt-get update

Once this is complete, enter (tip, you can copy this command and then right click in the command prompt to paste it):

sudo apt-get install git-core curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties

Once complete, enter:

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev

Next, enter:

curl -L | bash -s stable

If you get an error complaining about a key signature with the above command, enter the command mentioned under the error, followed by the previous command again. The command will look similar too:

gpg –keyserver hkp:// –recv-keys 1234567890ABCDEFGHIJKLMNOP

Some commands do not have any output, like the next command:

source ~/.rvm/scripts/rvm

Next, type:

echo “source ~/.rvm/scripts/rvm” >> ~/.bashrc

Next, type:

rvm install 2.1.5

Next, type:

rvm use 2.1.5 –default

If all of the previous commands worked, you should see output similar to the screen shot below after typing:

ruby –v

Ruby Version Output

Ruby Version Output

If your output looked like the screenshot above, type:

echo “gem: –no-ri –no-rdoc” > ~/.gemrc

We are almost done! We need to install node.js with:

sudo add-apt-repository ppa:chris-lea/node.js

A quick update with:

sudo apt-get update

The installation:

sudo apt-get install nodejs

And now for the magic install command to tie it all together:

gem install rails

Now that everything is installed, we can setup our first app.

The next command will set up the rails files for first use:

rails new blog

There will be a folder created called blog, go to it by typing:

cd blog

Now we want to used the rails framework to automatically generate some code for us. This will create the needed code for a simple submit page. Type:

rails generate scaffold Post name:string title:string content:text

Once complete (it could take a few minutes) enter:

rake db:migrate

Next, you will want to set up an endpoint for your VM so it knows where to listen for your Ruby on Rails server. From your Azure account, go to the Dashboard for your VM. Click on Endpoints, like below:

Entering an Endpoint

Entering an Endpoint

You will see a window pop-up after pressing the Add button, select Add A Stand-Along Endpoint. Next, press the arrow to continue.


Adding an Endpoint

Adding an Endpoint

You will need to select HTTP as the name of the endpoint, TCP for Protocol, 80 for Public Port, and 3000 for Private Port. After, press the check-mark to finish. Your settings should look similar to the screenshot below.


Endpoint Settings

Endpoint Settings

Now we can start our Rails server and try the simple app. From your command window from earlier, type:

rails server -b

Now you should be able to open your internet browser and go to the VM name you choose during setup. You need to add posts to the URL. Below is an example of the VM I setup.

Example Rails App

Example Rails App

If you press New Post you will see input that the scaffold created. And that’s it! You are done. Pat yourself on the back and call it a day.

Example Rails App

Example Rails App


Take the required screenshots and submit them for your points to #DevMov for some free gear from Microsoft.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *