Andy from Webcrunch

Subscribe for email updates:

Portrait of Andy Leverenz
Andy Leverenz

November 11, 2018

Last updated November 5, 2023

A Guide to Using Ruby on Rails Application Templates

As my experience with Ruby on Rails continues to grow I explore more and more by hitting the ground running with a base application template for new projects. In this guide, I'll discuss how I created my most recent template as well as what all get's included.

Ruby on Rails is by far the quickest path to a production worthy application that I know of. You can generate an entire blog in as little as 5 minutes using the built-in CLI. With that in mind, and my constant effort to provide tutorials around the framework, I took to building an application template for use going forward.

My Let's Build: With Ruby on Rails series has been a foundation for my learning of the framework. After several builds, I began to notice a lot of patterns involved in the way I needed to configure a new app each time I ran rails new.

Due to the nature of the tutorials, I wanted to provide "an approach from scratch" because many tutorials out there assume you know a lot before beginning. I still believe in this principle because practice makes perfect but in my particular case, I bypass a lot of the rudimentary configuration making use of an application template.

With an application template, you can create a new Rails app and define preconfigured decisions based on what you find you use the most in your past/current projects. Assuming you need to use a template, this can be a huge time saver.

This might not be for you if you really don't build a large number of apps but could prove worthy if you have ideas that you eventually want to build and don't want to waste time configuring the app.

What is a Ruby on Rails application template?

Application templates are simple Ruby files containing DSL for adding gems/initializers etc. to your freshly created Rails project or an existing Rails project.

In short, it's a way to install your favorite gems, configure your app, and even version control your project using one command.

How do I use the template?

If you're new to Ruby on Rails I invite you to check out my series so far linked at the bottom of this post. If you have some familiarity with the framework you may know by now that creating a new app is as simple as running rails new my_app.

Passing the template through works like this

$ rails new my_app -m template.rb

Here our CLI will look for a file called template.rb to guide it while it installs a new app.

You can download the latest template I created using Tailwind CSS out of the box. I called it kickoff_tailwind.

Download a copy of that and cd within the folder. There you can create your app by passing the template.rb file through as I stated before.

From there your app will scaffold and you can move the app folder wherever you like on your system.

What comes with it?

The included gems are:

  • devise
  • friendly_id
  • foreman
  • sidekiq
  • tailwindcss
  • webpacker

  • Webpack support + Tailwind CSS configured in the app/javascript directory.

  • Devise with a new username and name field already migrated in. Enhanced views using Tailwind CSS.

  • Support for Friendly IDs thanks to the handy friendly_id gem. Note that you'll still need to do some work inside your models for this to work. This template installs the gem and runs the associated generator.

  • Foreman support thanks to a Profile. Once you scaffold the template, run foreman start to initialize and head to locahost:5000 to get rails server, sidekiq and webpack-dev-server running all in one terminal instance. Note: Webpack will still compile down with just rails server if you don't want to use Foreman.

  • A custom scaffold view template when generating theme resources (Work in progress).

  • Git initialization out of the box


The entire Let's Build: With Ruby on Rails Series so far:

More Templates

Link this article
Est. reading time: 5 minutes
Stats: 4,829 views



Part of the Ruby on Rails collection