---
title: 'Hidden Gems: Suspenders'
teaser: Suspenders is all the boilerplate you need for a Rails app.
tags: web,ruby,open source,rails,suspenders
author: Mike Burns
published_on: 2012-09-25
---

Have you seen our [suspenders](https://rubygems.org/gems/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](https://camo.githubusercontent.com/affcb2f36d3224a70d62c32432cf4ac74f6e7461/687474703a2f2f6d656469612e74756d626c722e636f6d2f315445414d414c7073656835787a66304a7436626377534d6f315f3430302e706e67)

## 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](https://github.com/thoughtbot/laptop) script.

Suspenders will also install
[capybara-webkit](https://rubygems.org/gems/capybara-webkit) by default. Read
[the
instructions](https://github.com/thoughtbot/capybara-webkit/wiki/Installing-Qt-and-compiling-capybara-webkit)
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](https://gist.github.com/9b4135f4c83c6331d4c0) between it and a bare
Rails app.

## Gems

The gems are a mix of production libraries like
[newrelic](https://rubygems.org/gems/newrelic_rpm), development libraries like
[foreman](https://rubygems.org/gems/foreman), and testing libraries like
[timecop](https://rubygems.org/gems/timecop). The full list often changes, so
see
[`templates/Gemfile_clean`](https://github.com/thoughtbot/suspenders/blob/master/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](https://thoughtbot.com/blog/post/159807476/fourteen-hours-to-save-the-earth)
and Javascript partials, configuration for Heroku, Factory Bot, 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:

```html
<input type="text" class="prefilled" title="Email" name="user[email]" />
```

## 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](https://rubygems.org/gems/suspenders) for your next Rails app!
