Ruby on Rails with

by Daniel Kehoe

Last updated 25 May 2014

All about Ruby on Rails 4.1 on the hosted development environment.

With detailed instructions for getting started on with Rails including advice to get you fully productive.

If You Are New to Rails

If you’re new to Rails, see What is Ruby on Rails?, the book Learn Ruby on Rails, and recommendations for a Rails tutorial.

Join RailsApps

What is the RailsApps Project?

This is an article from the RailsApps project. The RailsApps project provides example applications that developers use as starter apps. Hundreds of developers use the apps, report problems as they arise, and propose solutions. Rails changes frequently; each application is known to work and serves as your personal “reference implementation.” Each application is accompanied by a tutorial so there is no mystery code. Support for the project comes from subscribers. Please accept our invitation to join the RailsApps project. provides a hosted development environment. Simply put, you get access to a remote computer from your web browser.

The Nitrous computer runs Ubuntu Linux, a popular operating system for Rails development. The online computer is instantly created with everything in place to immediately begin working on projects in Rails. This guide will orient you and provide additional details so you can be productive with Rails.


There is no cost to set up an account. You will only be charged if you decide to add extra storage or memory.

For ordinary Rails development, you don’t need extra storage or memory. For typical projects, the service is free.

Like other companies that offer basic services for free (such as Heroku for Rails hosting), hopes that full-featured free service will lead to popularity and revenues from upgrades. This approach greatly benefits anyone who needs to keep expenses low, especially startup founders, students, and developers in the world’s emerging economies.

The Service

The service gives you everything you need for Rails development, including:

  • Unix shell with Ruby pre-installed
  • browser-based file manager
  • browser-based text editor
  • project preview with your own web browser

For pair programming or other collaboration:

  • text chat for conversation
  • shared text editor
  • collaborate remotely

If you want to use your own Terminal application:

  • SSH access to the shell

Additionally, with Nitrous Desktop:

  • edit files directly with Sublime Text, Textmate or any other application

Scope and Limitations

The service offers enormous value. However, these limitations may make it unsuitable for you:

  • requires a fast broadband Internet connection
  • no root access to the server (no sudo or superuser access)

If you need root access to install a package, you can ask Nitrous support to do it.

In principle, allows you to do Rails development from any device that runs a web browser, including a tablet or smartphone. However, to be productive:

  • you need a decent-sized screen
  • you need a keyboard

Like any other Rails development environment:

  • you need basic Unix command-line skills

Benefits can be used on any operating system that provides a web browser and an Internet connection.

As an alternative to installing Ruby directly on your own computer, can be beneficial:

  • enables complete “cloud-based” development so no files are stored locally
  • provides an “extra computer” or alternative development environment
  • an alternative if you encounter difficulties installing Ruby on your own computer

Developers who travel frequently, or work at multiple sites, like cloud-based development because any computer provides access to a fully-configured, productive development environment. Additionally, cloud-based development means you will remain productive if your laptop is lost, stolen, or fails in service.

Mac OS X

Most Macintosh users will prefer to install Ruby on Rails on Mac OS X directly. However, can be beneficial for the reasons listed above. You can use your favorite Mac OS X text editor such as Sublime Text or Textmate to edit files on the Nitrous servers so primarily gives you a cloud-based shell and file storage.


The shell environment will be familiar to any Ubuntu Linux user. Unlike Linux virtual private servers from companies such as Linode, you won’t get root access and you can’t do your own system administration. However, the service is free and the system is maintained for you so you’ll spend more time as a developer and less time as a sysadmin. is particularly appropriate for newcomers who want to learn Unix but might be overwhelmed by the effort required to install and confgure Ubuntu Linux.


Installing Rails on Windows is frustrating and painful. I often hear that students have given up on learning Rails because installation of Ruby on Windows is difficult and introduces bugs or creates configuration issues. Even when you succeed in getting Rails to run on Windows, you will encounter gems you cannot install. For these reasons, is an ideal option for a Rails development environment on a Windows laptop. You will have to use the Nitrous browser-based text editor, as there is no option to use Sublime Text or other Windows text editors. If you are an expert with the Windows PowerShell or other terminal applications, you can SSH to the Nitrous shell as an alternative to using the Nitrous browser-based console.


A Chromebook is a personal computer running the Google Chrome OS operating system. Chromebooks are among the least expensive laptops available, selling for as low as $200 (US). Chromebooks are intended for cloud-based computing with no local storage and all applications running in the web browser. As such, is ideally matched to Chromebooks. At $200 (US), a Chromebook with is probably the least expensive way for a student to get a fully functional Rails development environment.

N2O Credits gives you enough memory and file storage to develop one or more moderately-complex Rails applications.

If you want more than one virtual computer, or you want to add memory and more file storage, you can purchase additional capacity. The company sells credits they call “N2O” which can be used to increase capacity.

All accounts come with 155 N2O credits, enough for a starter box, for free.

The company will give you additional N2O for free if you help expand their customer base by inviting friends or social sharing with Twitter.

What’ll Cost You

The company makes money by providing extra memory and file storage.

You may find that 750MB of storage is not enough for all your Rails applications. If you’re cloning repositories from your own GitHub account, you may need to rotate projects on and off your Nitrous box to fit the available storage. If that’s inconvenient, purchase more N2O and increase your storage capacity so you can keep a copy of all your repositories on your Nitrous box.

A compelling reason for purchasing an additional Nitrous box is to configure a second development environment. If you want to restrict sharing and collaboration to certain projects, and not allow your pairing partners access to all your projects, you may need a second box.

You may want to set up a second box for testing with a different configuration. More commonly, you’ll use RVM or another Ruby environment manager such as Chruby or Rbenv to switch among different versions of Ruby on just one box. You could purchase a second box to run a different version of Ruby. More likely, you’d purchase a second box to experiment or troubleshoot issues with your shell environment.

See the pricing page to determine how much you’ll spend for additional capacity.

Get a Account

Visit the website to sign up. You can create an account using your own email address and password or you can establish an account using your GitHub, Google, or LinkedIn account.

There is no cost to set up an account.

After you establish an account, you’ll see a button “Get Started” that gives an introductory tour. You can read through the tour in about five minutes.

See the Getting Started documentation for more.

Create a Box

A Nitrous “box” is a virtual computer. You get one for free, with 384MB of memory and 750MB of storage, which is enough to build and run one or more Rails applications.

To create a box, click the “Boxes” link in the navigation bar. Then click the “New Box” button.

Installing Rails on Nitrous - New Box

Make sure you’ve selected “Ruby/Rails”.

Enter a name for your box. Call it “ruby-uswest” or something else that shows the region and development enviornment you’ll use. Of course, if you prefer, you can give your box a clever pet name like “dragons-be-here.”

Select a region. For maximum speed and reduced network latency, use the region that is geographically closest to your Internet Service Provider.

You’ll get 155 N2O credits when you set up your account. You get an additional 5 N2O for confirming your email. If you’ve been given more, you can apply the credits to increase your storage capacity. With 160 credits, you can increase your storage from the minimum 750MB to 1GB.

Click the “Create Box” button and Nitrous will build your virtual computer in a few seconds.

See the Nitrous Creating a Box documentation for more.

The Web IDE

As soon as you’ve built a new box, you’ll see the Web IDE (Integrated Development Environment).

You can find your way back to the Web IDE by visiting the “Boxes” page, clicking the box name, and clicking the “IDE” button.

The navigation bar is simple, with just a few menu items. The Nitrous Web IDE is much more complex, because it is a full development environment that does the duty of a console, a file browser, a text editor, and a chat room.

Here’s the Web IDE for a new box.

Installing Rails on Nitrous - Web IDE

Take time to get familiar with the interface. For example:

Close the chat window (unless you are going to collaborate).

Drag the bar at the top of the console window to resize it. You’ll often need a bigger console window.

Click the icon to expand or minimize the console window. You’ll often need a full console window.

Click the “plus” icon to open a tab for a second console window. You’ll often need multiple console windows. For example, you might leave a Rails server running in one console while entering Rails commands in another.

See the Nitrous Getting Started with the WebIDE for more.

Let’s use the console to explore the Nitrous workspace and create a Rails application.

Unix Commands

If you haven’t used the Unix command line interface (CLI) before, spend some time with The Command Line Crash Course to become comfortable with Unix shell commands.

Directory Structure

Expand the console window and use Unix commands to explore the directory structure:

action@ruby-uswest-21609:~$ pwd
action@ruby-uswest-21609:~$ echo $SHELL
action@ruby-uswest-21609:~$ ls -la
total 52
drwxr-xr-x  1 action action 4096 Aug  5 23:39 .
drwxr-xr-x  1 root   root     19 Aug  5 23:38 ..
-rw-r--r--  1 action action  220 Apr  3  2012 .bash_logout
-rw-r--r--  1 action action  166 Jul 30 03:34 .bash_profile
-rw-r--r--  1 action action  736 Jul 30 03:36 .bashrc
drwx------  2 action action   33 Aug  5 23:39 .cache
drwxrwxr-x  1 action action   29 Jun 19 10:05 .gem
-rw-r--r--  1 action action   76 Jul 30 03:33 .gemrc
-rw-r--r--  1 action action  134 Jul 30 03:33 .gitconfig
drwxr-xr-x  6 action action 4096 Jul 30 03:37 .nvm
-rw-r--r--  1 action action  675 Apr  3  2012 .profile
drwxrwxr-x 23 action action 4096 Jul 30 03:34 .rvm
drwxrwxr-x  2 action action   36 Aug  5 23:38 .ssh
-rw-r--r--  1 action action   88 Jul 30 03:33 .tmux.conf
-rw-r--r--  1 action action   26 Jul 30 03:49 .VERSION
drwxr-xr-x  2 action action    6 Aug  5 23:38 workspace
-rw-rw-r--  1 action action  118 Jul 30 03:34 .zprofile
-rw-rw-r--  1 action action   59 Jul 30 03:34 .zshrc

The user home directory is home/action/. The Unix command cd ~ always takes you back here.

The Unix command echo $SHELL shows you that you are using the Bash shell.

The ls -la command lists all the hidden files and folders.

If you have some experience with a Unix environment or Rails, you’ll recognize configuration files for some familiar tools:

  • bash – the default shell
  • git – the version control system
  • nvm – the node version manager for managing node.js versions
  • rvm – the Ruby version manager
  • ssh – a folder containing public keys for conencting to GitHub
  • tmux – for multiple terminal sessions
  • zsh – an alternative to bash

Unix Command Prompt

You’ll see that has set an informative Unix command prompt for your shell:

action@ruby-uswest-21609:~$ whoami

“Action” is the username for any Nitrous user. The virtual computer name is shown, as well as the current directory, followed by the familar $ Unix command prompt.

For brevity, for the rest of this tutorial, I’ll show the command prompt as simple $.

Workspace Directory

When your box is created, there is one directory named workspace/.

$ pwd
$ ls

It is important to create your projects inside this folder.

If you use the Nitrous client application for Mac OS X, the user home directory will not be available in your Mac filesystem. The workspace/ is mounted in your Mac filesystem so you can edit files directly with a text editor such as Sublime Text. If you put projects in the user home directory, you will not be able to edit them directly on your Mac OS X computer.


A recent version of Ruby is pre-installed:

$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-linux]

Ruby 2.1.2 was current when this was written. You can check for the current recommended version of Ruby. If is not up to date, contact support and nag them to update the Ruby version. Or use RVM to install a newer version yourself.

For a newer version of Ruby, use RVM:

$ rvm install 2.1.2

If you need an older version of Ruby, you can install it with RVM:

$ rvm install 1.9.3

As new versions of Ruby are released, you’ll need an easy way to switch between versions. I recommend RVM to manage your Ruby versions because it is popular, well-supported, and full-featured. If you are an experienced Unix user, you can consider alternatives such as Chruby, Sam Stephenson’s rbenv, or others on this list.


RVM, the Ruby Version Manager, is pre-installed.

You should update RVM:

$ rvm get stable

Check which Ruby versions are installed:

$ rvm list

rvm rubies

=* ruby-2.1.2 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

If you have trouble installing Ruby with RVM, see the article Installing Ruby for installation troubleshooting and advice.


A recent version of Rails is pre-installed at the system level:

$ rails -v
Rails 4.0.0

Check for the current version of Rails. If you need a newer version of Rails, you can install it in an RVM gemset (no need to nag support on this). Details below.

When a new version of Rails is released, you can update the system-level Rails gem, or you can install Rails into an RVM gemset. It is best to install Rails into project-specific gemsets, so each project has the appropriate version of Rails and its dependencies.

Check the Gem Manager

RubyGems is the gem manager in Ruby.

Check the installed gem manager version:

$ gem -v

You should have:

Use gem update --system to upgrade the Ruby gem manager if necessary.

System Gems

You can see a list of all the gems that are pre-installed at the system level:

$ gem list
### list not shown for brevity

You can see the location in the file system where these gems are stored:

$ gem which rails

You’ll never directly move or remove the gem files but it is helpful to know that they are being managed by RVM.

Updating System Gems

A trouble-free development environment requires the newest versions of the system gems.

Several gems are installed with Ruby:

Others are part of the system installation of Rails.

To get a list of gems that are outdated:

$ gem outdated
### list not shown for brevity

To update all stale gems:

$ gem update
### list not shown for brevity

RVM Gemsets

Not all Rails developers use RVM to manage gems, but many recommend it.

Display a list of gemsets:

$ rvm gemset list

gemsets for ruby-2.1.2 (found in /home/action/.rvm/gems/ruby-2.1.2)
=> (default)

Only the “default” and “global” gemsets are pre-installed.

If you get an error “rvm is not a function,” close your console and open it again.

RVM Default Gems

Installing Ruby with RVM creates just two gemsets, the default and global gemsets.

Display a list of gems installed in the default gemset:

$ rvm gemset use global
Using ruby-2.1.2 with gemset global
$ gem list

*** LOCAL GEMS ***

bundler (1.3.5)
bundler-unload (1.0.1)
rake (10.1.0)
rubygems-bundler (1.3.3)
rvm (

Updating RVM Default Gems

A trouble-free development environment requires the newest versions of the RVM default gems:

To get a list of gems that are outdated:

$ gem outdated
### list not shown for brevity

To update all stale gems:

$ gem update
### list not shown for brevity

Staying Informed

You can stay informed of new gem versions by creating an account at and visiting your dashboard. Search for each gem you use and “subscribe” to see a feed of updates in the dashboard (an RSS feed is available from the dashboard).

After you’ve built an application and set up a GitHub repository, you can stay informed with Gemnasium or VersionEye. These services survey your GitHub repo and send email notifications when gem versions change. Gemnasium and VersionEye are free for public repositories with a premium plan for private repositories.

Create a New Gemset

Here’s how to create a new gemset for a project named “myapp”:

$ rvm use ruby-2.1.2@myapp --create
Using /home/action/.rvm/gems/ruby-2.1.2 with gemset myapp

You’ll see it in the list:

$ rvm gemset list
gemsets for ruby-2.1.2 (found in /home/action/.rvm/gems/ruby-2.1.2)
=> myapp

Rails Installation Options

Check for the current version of Rails. Rails 4.1.1 was current when this was written.

When a new version of Rails is released, you can update the system-level Rails gem, or you can install Rails directly into the global gemset. However, many developers prefer to keep the global gemset sparse and install Rails into project-specific gemsets, so each project has the appropriate version of Rails.

Let’s consider the options you have for installing Rails.

If you want the most recent stable release:

$ gem install rails
$ rails -v

If you want the newest beta version or release candidate, you can install with --pre.

$ gem install rails --pre
$ rails -v

Or you can get a specific version.

For example, if you want the Rails 3.2.18 release:

$ gem install rails --version=3.2.18
$ rails -v

New Rails 4.1 Application

To create a new Rails application using the default starter app, change directory into the workspace/ folder:

$ cd ~
$ pwd
$ cd workspace

The Unix command prompt changes to show you the current directory.

Here’s how to create a project-specific gemset, installing the current version of Rails 4.0, and creating a new application.

$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.1.2@myapp --ruby-version --create
$ gem install rails
$ rails new .

We’ll name the new application “myapp.” Obviously, you can give it any name you like.

With this workflow, you’ll first create a root directory for your application, then move into the new directory.

With one command you’ll create a new project-specific gemset. The option “—ruby-version” creates .ruby-version and .ruby-gemset files in the root directory. RVM recognizes these files in an application’s root directory and loads the required version of Ruby and the correct gemset whenever you enter the directory.

When we create the gemset, it will be empty (though it inherits use of all the gems in the global gemset). We immediately install Rails. The command gem install rails installs the most recent release of Rails.

Finally we run rails new .. We use the Unix “dot” convention to refer to the current directory. This assigns the name of the directory to the new application.

This approach is different from the way most beginners are taught to create a Rails application. Most instructions suggest using rails new myapp to generate a new application and then enter the directory to begin work. Our approach makes it easy to create a project-specific gemset and install Rails before the application is created.

The rails new command generates the default Rails starter app. If you wish, you can use the Rails Composer tool to generate a starter application with a choice of basic features and popular gems.

For a “smoke test” to see if everything runs, display a list of Rake tasks.

$ rake -T

Despite what you might read elsewhere, there’s no need to run bundle exec rake instead of rake when you are using RVM (see RVM and bundler integration).

You can launch and run the application with the Rails server:

$ rails server

Let’s take a closer look at the Web IDE now that we have created a Rails application.

Using the Web IDE with Rails

Here’s the Web IDE after we’ve created a Rails application and launched the Rails server.

Installing Rails on Nitrous - Rails Application in the Web IDE

A single console window is open, running the Rails server, and showing server log messages.

In the file browser, we’ve expanded the folder hierarchy and selected the application Gemfile.

The Gemfile is open in the text editor.

This is everything we need to develop a Rails application, except a browser to show us the application.

Previewing a Rails Application

Select “Preview” in the navigation bar.

Select “Port 3000” in the Preview menu.

A new browser tab will open displaying the application.

Installing Rails on Nitrous - Rails Application Preview

This is the default Rails starter application.

Stopping the Rails Server

You can stop the server with Control-c to return to the command prompt.

Most of the time you’ll keep the web server running as you add or edit files in your project. This a reason to open multiple console windows.

Changes will automatically appear when you refresh the browser or request a new page. There is a tricky exception, however. If you make changes to the Gemfile, or changes to configuration files, the web server must be shut down and relaunched for changes to be activated.

Working on a remote server means you can lose a connection (or close your console window) while the server is still running. If that happens, you may find you cannot start the server because you get an error, “A server is already running.” Use the provided PID file to find the Unix process ID and then stop the server with the Unix kill -9 PID command.

$ rails server
A server is already running. Check /home/action/workspace/myapp/tmp/pids/
$ cat /home/action/workspace/myapp/tmp/pids/
$ kill -9 4640

The Unix kill -9 command will stop the abandoned server process. If not, go to “Boxes” in the Web IDE and use the button to restart your Nitrous box.

Configure Git

Git is an essential tool for developing with Rails. With Git, you can roll back code changes as needed, collaborate on code with others, and deploy your application for hosting on Heroku. See the article Rails with Git and GitHub for more information.

Git is pre-installed on your Nitrous box. Check that Git is installed:

$ git version
git version

You must configure Git before you can use it:

$ git config --global "Real Name"
$ git config --global ""

Use your real name so people will associate you with your work when they meet you in real life. There’s no reason to use a clever name unless you have something to hide. Here’s another tip: Life will be easier if you use the same email address for Git, your GitHub account, and Heroku.

Check that Git is configured correctly:

$ git config -l --global
. Name

Configure GitHub Access

Rails developers use GitHub, the “social coding” website, for collaboration and remote backup of projects. GitHub is absolutely essential to all open source Rails development (and most proprietary development as well). Get a free personal GitHub account if you don’t already have one.

There are two ways to “clone” (download) project repositories from GitHub. GitHub suggests using the https protocol because it works even when you are behind a firewall. On a Mac, you can set up Git so you don’t have to enter a username and password when you “push” (upload) your changes to GitHub. With https on Linux, you’ll have to enter your username and password each time.

For greater convenience, use the git protocol when you clone a GitHub repository. On a GitHub project page, look for the tiny text, “You can clone with HTTPS, SSH, Subversion, and other methods” and choose SSH.

To avoid entering your username and password every time you push to GitHub, set up SSH keys to establish a secure connection between your Nitrous box and GitHub.

Nitrous has already created an SSH public key for you. View it with the Unix cat command:

$ cat ~/.ssh/
ssh-rsa 094fa31ab0 ... deafdc0d==

Carefully copy the entire string (it’s longer than the example shown here).

Log in to your GitHub and go to “Account Settings” (the tiny wrench and screwdriver at the upper right corner of any page).

Select “SSH Keys” in the left sidebar. Click “Add SSH key”.

Enter any helpful name in the “Title” field, such as “nitrous-ruby-uswest”.

Carefully paste your key into the “Key” field.

Click the “Add key” button. Confirm the action by entering your GitHub password.

Check that your GitHub account is set up properly. Enter “yes” when prompted to continue.

$ ssh -T -p 443
The authenticity of host '[]:443 ([]:443)' can't be established.
RSA key fingerprint is 16:27:ac:a ... df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[]:443,[]:443' (RSA) to the list of known hosts.
Hi DanielKehoe! You've successfully authenticated, but GitHub does not provide shell access.

The command establishes a secure SSH connection from your Nitrous box to port 443 on the GitHub server. The first time you connect, your Nitrous box will warn you that it has never connected to the server and can’t be sure the host is legitimate and secure. Unless you are a target of a sophisticated hacking scheme, you can safely answer “yes” when prompted.

If your SSH key is set at your GitHub account, the GitHub server will confirm you’ve successfully connected and inform you that “GitHub does not provide shell access.” That just means you can’t log in to GitHub and use their servers the way you are using your Nitrous box as your personal console. That’s fine; GitHub is not used for remote shell services.

With SSH keys saved to your GitHub account, you can use GitHub without entering your username and password every time you push.

Text Editing on Mac OS X

Nitrous provides a fully functional text editor within the Web IDE browser. You can use it from any computer, whether Mac, Linux, Windows. If you prefer the Vim text editor, or Emacs, you can use your console to edit text.

Mac OS X users who prefer full-featured text editors such as Sublime Text or Textmate can download and install Nitrous Desktop.

The Nitrous Desktop application works like Dropbox, the file hosting service. A folder in your Mac filesystem contains a copy of all the folders and files in the workspace/ folder of your Nitrous box and automatically synchronizes the files. This means that any application on your Mac can manipulate the files stored on your Nitrous box. And not just text editors; you can use full-featured applications such as Eclipse or RubyMine, or any other application you like.

Start by downloading the Nitrous Desktop application. After installing the application, it will ask where to mount the Nitrous workspace/ folder. You can set your Nitrous username and password and generate and register SSH keys to set up a secure connection to your Nitrous box.

The Nitrous application is available from your Mac OS X menu bar. You’ll see a listing for your Nitrous box (such as “ruby-uswest”). You can launch the Mac Terminal application from the Nitrous application to access your Nitrous box shell. Or you can launch the Web IDE from the Nitrous application menu.

In your Mac OS X home directory, you’ll find a folder. All the files from your Nitrous box are there.

Just drag the files from your Mac Finder to your text editor. Or use your text editor to open the files directly.

As you make changes and save a file, you’ll see a brief notification that your files are being synchronized with the Nitrous box.

In many ways, this is the best of all worlds. Your project files are backed up to your Nitrous box (where you can commit changes to GitHub), and you’ll use your Nitrous box to run your applications, so you are working “in the cloud.” But you can use a native Mac text editor with full mouse and keyboard support.

See the Nitrous Mac App Preferences documentation for more information.

Local Shell Access

Just as you can use your favorite text editor (on Mac OS X only), you can use your favorite Terminal application to connect to the shell running on your Nitrous box (from Linux, Mac, or Windows). This is primarily an option for experienced users; the Web IDE console is fine for beginners. See the Nitrous Connecting to box via SSH documentation for more information.

Fancy Prompts and More

Experienced Unix users often configure the shell with a fancy prompt, environment variables, and command aliases. You can switch to the Z shell and install Robby Russell’s oh-my-zsh for the ultimate power user experience (experts only!).

Bash-it is a simpler alternative to oh-my-zsh if you want to continue to use the Bash shell. It’s easy to install if you just want a fancy prompt and a library of command aliases.

$ git clone .bash_it
$ ~/.bash_it/

During the initial install, choose “none” for each prompt to avoid installing more than you need. You can run bash-it show aliases later to pick command aliases for the tools you use.

Close and reopen the console to enable Bash-it and see your new prompt. Bash-it offers a choice of “themes” that give you different prompts.

A fancy prompt will show you the git status of your current directory as well as the current RVM gemset. And, of course, it will impress your friends.


You can use your Nitrous box for pair programming.

Your pairing partner must have a Nitrous account. Begin a pairing session by selecting the “Collaborate” link in the Web IDE navigation bar. To avoid confusion, note that two other navigation bar links, “Connect” and “Invites” are not for collaboration.

“Toggle Chat,” in the “Collaborate” menu, opens and closes the chatroom window. You can text chat with your pairing partner in the chatroom. Messages in the chatroom will display names of files your partner has opened. The name of the file is a link; clicking on the filename is a good way to open the file to begin work together. You must click the tab for “Collab Mode” in the text editor to see your partner typing in the file.

Collaboration is limited to the text editor and the chatroom. Your console windows (and your partner’s console windows) are not shared, so your partner cannot see what you are doing in your console. If you want to share a console, you can run Tmux, a terminal multiplexer, which lets you switch between multiple sessions in one console window, and leave sessions running between logins.

If you are physically present with your partner, at a shared desk or in the same room, Nitrous is a good way to edit a project using two keyboards and two displays.

For remote collaboration, open a browser window for video chat (such as Google Hangouts) or use Skype for conversation. You can screenshare with video chat if your partner needs to see your full screen.

See the Nitrous Getting Started with Collaboration for more information.

Rails Starter Apps

The starter application you create with rails new is very basic.

Use the Rails Composer tool to build a full-featured Rails starter app.

You’ll get a choice of starter applications with basic features and popular gems.

Here’s how to generate a new Rails application using the Rails Composer tool:

Using the conventional approach:

$ rails new myapp -m

Or, first creating an empty application root directory:

$ mkdir myapp
$ cd myapp
$ rvm use ruby-2.1.2@myapp --ruby-version --create
$ gem install rails
$ rails new . -m

You can add the -T flags to skip Test::Unit if you are using RSpec for testing.

You can add the -O flags to skip Active Record if you are using a NoSQL datastore such as MongoDB.

Rails Tutorials and Example Applications

The RailsApps project provides example apps that show how real-world Rails applications are built. Each example is known to work and can serve as your personal “reference implementation”. Each is an open source project. Dozens of developers use the apps, report problems as they arise, and propose solutions as GitHub issues. There is a tutorial for each one so there is no mystery code. Purchasing a subscription for the tutorials gives the project financial support.

Example Applications for Rails 4.1 Tutorial Comments
Learn Rails Learn Ruby on Rails introduction to Rails for beginners
Rails and Bootstrap Tutorial starter app for Rails and Bootstrap
Rails and Foundation Tutorial starter app for Rails and Zurb Foundation
OmniAuth and Rails OmniAuth for authentication
Devise and Rails Tutorial Devise for authentication
Pundit and Rails Tutorial Pundit for authorization

Adding a Gemset to an Existing Application

If you’ve already created an application with the command rails new myapp, you can still create a project-specific gemset. Here’s how to create a gemset for an application named “myapp” and create .ruby-version and .ruby-gemset files in the application’s root directory:

$ rvm use ruby-2.1.2@myapp --ruby-version --create

You’ll need to install Rails and the gems listed in your Gemfile into the new gemset by running:

$ gem install rails
$ bundle install

Specifying a Gemset for an Existing Application

If you have already created both an application and a gemset, but not .ruby-version and .ruby-gemset files, here’s how to add the files. For example, if you want to use an existing gemset named “ruby-2.1.2@myapp”:

$ echo "ruby-2.1.2" > .ruby-version
$ echo "myapp" > .ruby-gemset

Using .ruby-version and .ruby-gemset files means you’ll automatically be using the correct Rails and gem version when you switch to your application root directory on your local machine.


Rails uses the SQLite database by default. Your Nitrous box comes with SQLite pre-installed and there’s nothing to configure.

Though SQLite is adequate for development (and even some production applications), a new Rails application can be configured for other databases. The command rails new myapp --database= will show you a list of supported databases.

Supported for preconfiguration are: mysql, oracle, postgresql, sqlite3, frontbase, ibm_db, sqlserver, jdbcmysql, jdbcsqlite3, jdbcpostgresql, jdbc.

For example, to create a new Rails application to use PostgreSQL:

$ rails new myapp --database=postgresql

The --database=postgresql parameter will add the pg database adapter gem to the Gemfile and create a suitable config/database.yml file.

Don’t use the --database= argument with the Rails Composer tool. You’ll select a database from a menu instead.

Nitrous doesn’t host any database systems other than SQLite. However, Nitrous provides connections to hosted database services. At this time you can choose:

See the Nitrous Databases documentation to set up database connections for your application.


If you wish to run your own servers, you can deploy a Rails application using Capistrano deployment scripts. However, unless system administration is a personal passion, it is much easier to deploy your application with a “platform as a service” provider such as Heroku.


For easy deployment, use a “platform as a service” provider such as:

Deploy to Heroku

For deployment on Heroku, see the article:

If you’ve cloned an application from GitHub that you’ve deployed previously, you’ll need to add a git remote to deploy it from your Nitrous box:

$ heroku git:remote -a myapp
Git remote heroku added.

To push your code to Heroku, you’ll need to add SSH keys for your Nitrous box to Heroku:

$ heroku keys:add
Found existing public key: /home/action/.ssh/
Uploading SSH public key /home/action/.ssh/ done

You can learn more about Managing Your SSH Keys on Heroku.


By design, Rails encourages practices that avoid common web application vulnerabilities. The Rails security team actively investigates and patches vulnerabilities. If you use the most current version of Rails, you will be protected from known vulnerabilities. See the Ruby On Rails Security Guide for an overview of potential issues and watch the Ruby on Rails Security Mailing List for announcements and discussion.

Your Application’s Secret Token

Rails uses a session store to provide persistence between page requests. The default session store uses cookies. To prevent decoding of cookie data and hijacking a session, Rails encypts cookie data using a secret key. When you create a new Rails application using the rails new command, a unique secret key is generated and written to the config/initializers/secret_token.rb file. If you’ve generated a Rails application and committed it only to a private GitHub repository, you do not need to change the secret key. However, if you’ve cloned a public GitHub repository or made your application publicly available on GitHub, you must change the secret key when you deploy. The command rake secret generates a new random secret you can use. The command won’t install the key; you have to copy the key from the console output to the config/initializers/secret_token.rb file. Remember, you should never deploy an application to production that uses a publicly available secret token (obviously, it is not secret if it is public!).

Where to Get Help provides support for users.

You can also find help on Stack Overflow. Your issue may have been encountered and addressed by others.


Daniel Kehoe wrote the article. Thank you to Erik Trautman of the Odin Project for editing and review.

Get the book Learn Ruby on Rails to and join RailsApps if the article was helpful.

Learn Ruby on Rails


Is this helpful? Your encouragement fuels the project. Please tweet or add a comment. Couldn't get something to work? For the example apps and tutorials, it's best to open an issue on GitHub so we can help you.

comments powered by Disqus