b8-rails-template-maguroAs software consultants we often find ourselves doing the same configuration and setup for all our client and personal projects. It’s not hard, but it’s tedious and can take many hours to set up a new rails project just the way we want. Enter Rails Application Templates. Rails application templates allow you to create templates that configure a new application just the way you want. You can add gems, modify files, add git commits, and do a host of other actions. Check out their documentation for more information. Once you’ve created the template, you can generated a custom rails project with a simple command:

rails new blog -m ~/my_template.rb

Now, every new project you create will have all the configurations you want! No more removing turbolinks for me! Woo Hoo!

Our Template

After spinning up a lot of new projects and figuring out what type of configuration we liked, we created our template that you can find on Github. It does the following for you:

    1. Saves RVM configuration files
    2. Creates a basic README file
    3. Configures the project to use Postgres
    4. Installs and configures Rspec and a host of other testing gems
    5. Generates a secret app environment variables file
    6. Removes Turbolinks
    7. Creates a default homepage and controller
    8. Sets up a local git repository, gitignore file, and checks in all changes
    9. Creates a master and develop branch in Git

And optionally

  1. Creates a production and staging app on Heroku and pushes to it
  2. Creates a remote git repository on Bitbucket or Github

These steps are always the same for pretty much every project we create, so not having to recode them saves us a lot of time and headache. If you find yourself in a similar situation doing the same configurations over and over, try creating your own rails application template. It can save you many boring hours down the line.

Leveraging other People’s Templates

If you don’t feel like creating your own application template, there are a couple existing and actively maintained rails application templates out there that you can use.

Suspenders is full feature rails application template created and used by the awesome Thoughtbot team. They integrate a number of gems that they always use as well as have some neat features like creating a github project and creating heroku projects.

Rails Composer is another rails application generator that is kept update. It gives you the option to create a number of different preconfigured rails applications depending on what features you want. For example it can create an app with devise already installed.

If those don’t suit you, you can always fork and use our template :).

The Future

There are a couple new companies that are trying to go further than what suspenders and rails composer are doing right now. Both Prelang and Drystorm provide a simple web interface to be able to choose a bunch of different components and automatically create a new rails project in seconds. They are both pre-launch, so you should definitely keep an eye on them for the future.