Skip to content

Application template for Rails 6 projects; preloaded with best practices for TDD, security, deployment, and developer productivity.

License

Notifications You must be signed in to change notification settings

leikir/rails-template

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

leikir/rails-template

Requirements

This template currently works with:

  • Rails 6.0.x
  • PostgreSQL
  • Yarn

Usage

This template assumes you will store your project in a remote git repository (e.g. Bitbucket or GitHub) and that you will deploy to a production environment. It will prompt you for this information in order to pre-configure your app, so be ready to provide:

  1. The git URL of your (freshly created and empty) Bitbucket/GitHub repository
  2. The hostname of your production server

To generate a Rails application using this template, pass the -m option to rails new, like this:

For a standalone Rails app

rails new blog \
  -d postgresql \
  -m https://raw.githubusercontent.com/leikir/rails-template/master/template.rb

For a Rails API (with/without React)

rails new blog \
  -d postgresql \
  --api \
  --skip-bundle \
  -m https://raw.githubusercontent.com/leikir/rails-template/master/template.rb

Remember that options must go after the name of the application. The only database supported by this template is postgresql.

What does it do?

The template will perform the following steps:

  1. Generate your application files and directories
  2. Ensure bundler is installed
  3. Create the development and test databases
  4. Install a bunch of extensions

What is included?

These gems are added to the standard Rails stack

  • Core
    • sidekiq – Redis-based job queue implementation for Active Job
    • [Rollbar][] – Error monitoring
  • Utilities
  • Security
  • Testing
    • simplecov – code coverage reports
    • [rspec][] – Framework for tests

How does it work?

This project works by hooking into the standard Rails application templates system, with some caveats. The entry point is the template.rb file in the root of this repository.

Normally, Rails only allows a single file to be specified as an application template (i.e. using the -m <URL> option). To work around this limitation, the first step this template performs is a git clone of the mattbrictson/rails-template repository to a local temporary directory.

This temporary directory is then added to the source_paths of the Rails generator system, allowing all of its ERb templates and files to be referenced when the application template script is evaluated.

Rails generators are very lightly documented; what you’ll find is that most of the heavy lifting is done by Thor. The most common methods used by this template are Thor’s copy_file, template, and gsub_file. You can dig into the well-organized and well-documented Thor source code to learn more.

About

Application template for Rails 6 projects; preloaded with best practices for TDD, security, deployment, and developer productivity.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 85.2%
  • HTML 9.9%
  • Shell 2.2%
  • JavaScript 1.9%
  • Other 0.8%