How to develop a Rails app using Github and Nitrous

Share this post!

Why to try Nitrous, another tool in town?

One thing that I believe is crucial in the software development field is the collaboration among developers. As a programmer you should be able to easily show your code to your colleagues either because you need to comment some feature, to check your objects’ design or for whatever other reason you can imagine. Follow this approach and you will improve the quality of your software (and your happiness as a developer, by the way).

But the collaboration is difficult when the development platforms are different. The ‘It works on my machine Horror Show’ can be fought using, for instance, virtualised and reproducible environments using Vagrant or Docker (I show an example on this post about how to configure a development environment for Rails using Vagrant).

Following this idea a bit further, the best solution should be to use the same development environment, something external to the developers, something that handle at least the code editor and the shell.

As far as I can tell, this is what Nitrous is offering. It is also free to use for your small pet projects.

A quick example using a test Rails app

The easiest way to see the possibilities is to run a quick example, so let’s fire a navigator and go to nitrous.io. The easiest option is to log in is using your Github account – or you can create a new one – and click on ‘Open dashboard’.

You will end up on your Boxes’ manager showing the message ‘You have not created any boxes’. Boxes are the code containers, where you define the resources that your code will use – and therefore the price you will pay. Click on the ‘New Box’ button and select the ‘Ruby/Rails’ template.

You will see that you can set some parameters. The most important are the memory and the storage that your application will consume. Keep them at minimum for this example. To deploy software to this box I will use a Github repo with a test application. Don’t you have a test application? Don’t worry, you can use mine. This testapp is a (more or less) copy of the beginners’ guide “Adding Authentication with Devise” from Railsgirls.  You have just to write ‘https://github.com/memaker/test_devise_railsgirls.git’ on the ‘Download a Github repo’ field. Or better still, use the Nitrous Hack button:

Hack memaker/test_devise_railsgirls on Nitrous

Once created the box you will end up with the Nitrous IDE in all its beauty. The file manager, the code editor and the shell console are integrated. Let’s run this app.

Click to the ‘Console’, navigate to the working folder and run the app:

action@violet-beauty-69-216658:~$ cd workspace/test_devise_railsgirls
action@violet-beauty-69-216658:~$ bundle install
action@violet-beauty-69-216658:~$ rake db:migrate
action@violet-beauty-69-216658:~$ rails s -b 0.0.0.0

The last command binds the app to the IP 0.0.0.0 instead of localhost/127.0.0.1

To preview the app, just select ‘Preview – Port 3000’ on the IDE. Your navigator will be started with the right URL and you will see the app up and running. It’s just a test app that might not be fully functional, please don’t be rude with it!

And that’s nearly all, you probably know how to continuo from here.

There is only one thing to add. On the Nitrous web site you will see a ‘Desktop’ menu option. Following that you can install ‘Nitrous Desktop’, a (desktop, obviously) application for Windows and Mac users that creates a folder on your computer and synchronises the Nitrous files to it, so you can use your favourite editor to code. You will need to install your public key on Nitrous to allow access to Nitrous Desktop to your boxes; don’t worry, it is easy and it is well explained on this post.

Please try it, and I hope you enjoy.

Do you use Nitrous in your projects? I would like to know some first hand experiences using this tool in real projects. Thanks for share!

Image from http://help.nitrous.io/logos/