Rails 3 Ruby on Rails Tutorial sample application (plus mods!)
Ruby HTML CSS CoffeeScript JavaScript
Failed to load latest commit information.
lib Change out most forms to use SimpleForm Sep 5, 2012
spec Modularize Utilities Dec 15, 2013
.coveralls.yml Attempt using Coveralls Mar 11, 2013
Gemfile.lock Update Rails to 3.2.21 Nov 19, 2014
Guardfile Update Guardfile to match Rails Tutorial's Aug 9, 2012
README.md Add a Bitdeli badge to README Nov 6, 2013


Ruby on Rails Tutorial: sample application

Build Status Code Climate Coverage Status Security Status

This is the sample application for the Rails 3.2 version of Ruby on Rails Tutorial: Learn Rails by Example by Michael Hartl (plus some modifications).

(I'm not going to be maintaining this version of my Sample App anymore, so please find the Rails 4 version here).

  • This code is currently deployed here using Heroku
  • Translation keys are currently being managed here with Localeapp.

Cloning Locally

$ cd /tmp
$ git clone git@github.com:paulfioravanti/sample_app.git
$ cd sample_app
$ bundle install

Environment Configuration

$ cp config/application.example.yml config/application.yml

Inside Rails App

Generate a secret token:

$ rake secret

Copy the resulting string into the SECRET_TOKEN entry in config/application.yml, along with your database information:

# App keys
SECRET_TOKEN: # your rake secret generated token

  DB_NAME: # your dev db name here
  DB_USER: # your dev db username here
  DB_PASSWORD: # your dev db password here

  DB_NAME: # your test db name here
  DB_USER: # your test db username here
  DB_PASSWORD: # your test db password here

  DB_NAME: # your prod db name here
  DB_USER: # your prod db username here
  DB_PASSWORD: # your prod db password here

Testing with Travis CI

If you're using Travis for continuous integration testing, do the following (without the {{ }}):

Create encrypted travis variables for your Heroku API key and Repo name:

$ gem install travis
$ travis encrypt your_username/your_repo HEROKU_API_KEY={{YOUR_HEROKU_API_KEY}}
$ travis encrypt HEROKU_GIT_URL={{YOUR_HEROKU_GIT_URL}} # eg git@heroku.com:my_app.git
$ travis encrypt DB_NAME={{YOUR_DB_NAME_UNDER_TEST}} # eg: sample_app_test
$ travis encrypt DB_USER={{YOUR_DB_USER}}
$ travis encrypt DB_PASSWORD={{YOUR_DB_PASSWORD}}

Then add them to .travis.yml

    - secure: {{YOUR_ENCRYPTED_DB_USER}}

Deploying with Heroku

Generate production environment variables automatically using Figaro:

$ rake figaro:heroku

Or, do it manually:

$ heroku config:set SECRET_TOKEN={{YOUR_SECRET_TOKEN}}
$ heroku config:set DB_NAME={{YOUR_DB_NAME_UNDER_PRODUCTION}} # eg: sample_app_production
$ heroku config:set DB_USER={{YOUR_DB_USER}}
$ heroku config:set DB_PASSWORD={{YOUR_DB_PASSWORD}}


If you want to use Localeapp to manage language keys in the app (ignore this if you don't), create an account on their site, get an API key, and copy it into the LOCALE_API_KEY entry in config/application.yml, and add the key to your Heroku environment, if you didn't generate it automatically with Figaro:

$ heroku config:set LOCALE_API_KEY={{YOUR_LOCALE_API_KEY}}

New Relic

If you want to use New Relic for app metrics (ignore this if you don't), create an account on their site, get a license key, and copy it into the NEW_RELIC_LICENSE_KEY entry in config/application.yml, and add the key to your Heroku environment, if you didn't generate it automatically with Figaro:


Finally, configure the databases:

$ bundle exec rake db:migrate
$ bundle exec rake db:seed
$ bundle exec rake db:test:prepare RAILS_ENV=test


User Interface


  • Added locale switcher
  • Internationalized app labels with translations for Japanese and Italian
  • All static content internationalized in Markdown files instead of HTML/ERb files
  • Added i18n-specific routing
  • Added translations to dynamic data and its relevant sample data (microposts) using Globalize3


  • Moved development database over to Postgresql to match deployment database on Heroku.
  • Changed all views from HTML/ERb to Haml
  • Refactored SCSS files to use more mix-ins, as well as additions to add styling to the language selector
  • Used rails-timeago to do time calculation for microposts on client-side rather than server-side (replaces method calls to time_ago_in_words)
  • Simplified implementation of most forms with SimpleForm
  • Used Figaro to handle all secret keys in an attempt to remove any app-identifiable information from all environments. Reasons why at this StackOverflow thread
  • Moved mass assignment handling over to strong_parameters in anticipation of Rails 4




  • Fully automatic deployment process put in place: after a commit is pushed to Github, it gets pushed to Travis CI, and then gets deployed directly from the Travis worker to Heroku. See the .travis.yml for details and this StackOverflow thread for reference.


  • Tests for Javascript-based functionality: Follow/Unfollow button, micropost countdown, endless scroll
  • Tests for strong_parameters, if an appropriate method gets implemented before Rails 4 is released.


profile for Paul Fioravanti at Stack Overflow, Q&A for professional and enthusiast programmers


Bitdeli Badge