Hidden Gems: Suspenders

Have you seen our suspenders? It is a Rails app generator that includes a set of Ruby gems and common code that we use on every project.

Suspenders Boy

Install it

gem install suspenders

This will install gems with C code, which means you need your OS set up for that. On Debian you need rubygems and build-essential; on OS X you can use the laptop script.

Suspenders will also install capybara-webkit by default. Read the instructions for setting up your OS for it, or use the --webkit false option with the following command.

Create a Rails app

suspenders demo

This makes a demo app. See the difference between it and a bare Rails app.

Gems

The gems are a mix of production libraries like newrelic, development libraries like foreman, and testing libraries like timecop. The full list often changes, so see templates/Gemfile_clean for the exact list.

We selected these gems because we use them on most apps, they have tests, and they are maintained. Some of them are ours but most are from others in the community.

Common code

Suspenders includes a Guardfile, flash and Javascript partials, configuration for Heroku, Factory Girl, Bourbon, Postgres, and more:

  • An email address validator so you can do validates :login, email: true
  • A list of HTTP and SMTP exceptions that we have gathered through trial and error.
  • Prefilled form inputs using JavaScript for a nice user experience:

Even better Suspenders

Create Heroku staging and production apps with the --heroku option:

suspenders demo --heroku true

Create a GitHub project with the --github option:

suspenders demo --github organization/project

Use a different authentication library or no auth at all with the --clearance option:

suspenders demo --clearance false

Opt out of the capybara-webkit dependencies with the --webkit option:

suspenders demo --webkit false

Or, combine options:

 suspenders demo --heroku true --github organization/project --webkit false

That was easy

Suspenders should make your life easier. Reduce the tedious decisions, add the one-liners you wish you had, and set up the infrastructure common to every codebase.

Use suspenders for your next Rails app!

Mike Burns

Sharpen your programming skills by completing coding exercises that are reviewed by other developers at Upcase today.