Introducing Brewhouse's Rails Template
We’ve shipped over a dozen Ruby on Rails apps that all share the same base set of gems and configuration files. In order to save some time and ensure that our next web apps share a common set of best practices, we’ve put together the brewhouse-rails-template.
The brewhouse-rails-template is a Ruby on Rails 4.2 application ready to deploy to Heroku with popular gems configured to work nicely together and a self-destroying script to bootstrap your app by renaming all configuration and classes to your application name.
What about generators?
We reviewed the excellent Suspenders gem by Thoughtbot and found it bundles quite a number of gems we don’t use. Customizing it to suit our needs would have been quite difficult and maintaining a fork would have been even harder. However, we do recommend going through the code as it features a lot of nice tricks to get the most out of Rails.
We also experimented with building a Rails application template that we could use when creating a new Rails app to set up gems and modify configuration files. Making an application template turned out to be tedious as we would write code to inject code into existing code. It’s hard to understand what the template is trying to achieve and the output often does not look right (wrong indentation etc). On top of that, the feedback loop is quite slow as we would have to generate a brand new rails app everytime we made a change. When we started to write specs to test our application template, we decided to take the simpler approach of making a base rails app that we’ll keep updated as new versions of gems get published.
What’s in the box?
A Ruby on Rails 4.2 application ready to deploy to Heroku with popular gems
configured to work nicely together and a
bootstrap script that takes
care of renaming all configuration and classes to match your application
Usermodel setup and mailer previews available at
simple_formset up for bootstrap 3
virtusfor building service objects
schema_auto_foreign_keysfor a robust data layer where orphan records are not a thing
sidekiqwith dashboard at
bootstrap-sasswith a couple of defaults in
roadie-railsto inline css in emails so that GMail picks up the styles
dotenv-railsto store config and secrets in env variables
letter_openerto open emails in the browser in dev env
factory_girlwith generators integration setup
rspecfor unit testing
capybara-screenshotfor integration tests
simplecovbecause test coverage matters
puma‘cause it’s fast
rails_12factorto run the app on Heroku
heroku-deflaterto compress assets
rollbarto get notified about errors
newrelic_rpmto monitor performances
app.jsonto setup free add-ons (rollbar, newrelic, papertrail, etc.), environment variables and run migrations when you deploy to Heroku
Assuming you want to create “my-rails-app”:
Clone the `brewhouse-rails-template` repo:
git clone email@example.com:BrewhouseTeam/brewhouse-rails-template.git my-rails-app
Bootstrap your app (rename all configuration and classes to your application name)
cd my-rails-app && ./bootstrap my-rails-app
Et voilà! A great Rails app with solid foundations!
We hope you’ll find brewhouse-rails-template to be a solid starting point for your next rails app.
As always, questions, comments, and contributions are more than welcomed.