28 Jul

Our Rails Starter 'Template'

Last update on 2015-07-28

We want to share with the community a work that we began a little over two weeks ago, the main idea was to have a Rails starter template with the minimal bases for building common rails applications, we had analysed several options and existent resources (for example awesome-ruby, rails-wizard, rails-composer, suspenders, among others). These are very good tools, however, we needed a more concept-oriented resource for ourselves, think of it as a kind of inception which will cover all critical aspects in the most common development areas.

Our Rails Starter Template


Our goals were to define an homogeneous base of knowledge, speed up our development process, minimize some common errors and define a good base for our best practices in coding, all of these as a part of strengthening our development style.

At the beginning, we just had in mind to define and use existing tools and gems in the following areas: security, configuration, code quality, testing, performance, debugging and frontend. However, in the template building process we have created our own approaches and libs for managing some resources different than Rails commonly does it.

What's this 'template' good for?

This basic Rails application template addresses the most common scenario for a standard Rails application; and includes best practices, configurations for production environment, and a comprehensive readme file explaining the different gems and custom configurations.

For example, the template uses a layout inheritance approach to include in every page your analytics scripts or any other code you need.

We have also included basic code quality and basic security gems and tools. We propose a new structured pattern to organize your Sass files that we have named Sassish, and a dead-simple pattern for organizing and including Javascript code.

For application configuration we suggest improved mechanisms for the secrets.yml file and use of environment variables (ENV) using the gem dotenv.

Other gem included are: RSpec, Database cleaner, Capybara, simplecov, phantomjs+poltergeist, and pry and friends among others Please read the README for information on additional gems and techniques included.


Just take me to the template... here it is:


At the time of this writing, the template is only at its first version, all information is contained in the readme and we are pretty sure that this could be useful to any development team.

Take into account that this first version uses Mongoid, however migrating to ActiveRecord is not a difficult task (we are planning on doing an ActiveRecord based template too anyway). Try checking out the latest notes to see our initial thoughts on migrating to ActiveRecord (basically, just more gems to include).

Finally, we are thinking about modularizing our template, using the built-in rails templating approach or perhaps go in a totally different direction using a "git apply patch" strategy in order to be able to modify existing applications, instead of just when creating a new one.

As you can see, the template is a rails project in itself, it is not a rails template (the ones you install as rails new myapp -m path/or/url/to/template/here). The reason for this is that we chose to have it as baked as possible.

We would like to keep this post as a short introductory post and for you to check out the repo as all information is contained in more detail in the README file.

comments powered by Disqus