This is a fork of mattbrictson/rails-template with lots of customizations based on our workflow.
This is a Ruby on Rails project template to kickstart development of new projects. This is a fairly opinionated template based on our experience and preferred style.
This template currently works with:
- Rails 6.0.x
- PostgreSQL
- Redis
Optional.
To make this the default Rails application template on your system, create a ~/.railsrc
file with these contents:
-d postgresql
-m https://raw.githubusercontent.com/johnkoht/rails-template/master/template.rb
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:
- The git URL of your (freshly created and empty) Bitbucket/GitHub repository
- The hostname of your production server
To generate a Rails application using this template, pass the -m
option to rails new
, like this:
rails new blog \
-d postgresql \
-m https://raw.githubusercontent.com/johnkoht/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
.
If you’ve installed this template as your default (using ~/.railsrc
as described above), then all you have to do is run:
rails new blog
The template will perform the following steps:
- Generate your application files and directories
- Ensure bundler is installed
- Create the development and test databases
- Commit everything to git
- Push the project to the remote git repository you specified
There are a bunch of gems included in the project, most are based on personal preference and experience.
Server
Application Gems
Background Workers
- sidekiq Simple, efficient background processing for Ruby
- sidekiq-cron Scheduler / Cron for Sidekiq jobs
- sidekiq-failures Keep track of Sidekiq failed jobs
UI/Views
- bootstrap Mixins, scaffolding, layout
- meta-tags Search Engine Optimization (SEO) for Ruby on Rails applications
- rack-canonical-host Rack middleware for defining a canonical host name
- sass-rails Ruby on Rails stylesheet engine for Sass
- simple_form Forms made easy for Rails! It's tied to a simple DSL, with no opinion on markup
- turbolinks Turbolinks makes navigating your web application faster
- webpacker Use Webpack to manage app-like JavaScript modules in Rails
Monitoring/Exceptions
- honeybadger Ruby gem for reporting errors to honeybadger.io
Development Gems
- active_record_query_trace Rails plugin that logs/displays a backtrace of all SQL queries executed by Active Record
- annotate Annotate Rails classes with schema and routes info
- awesome_print Pretty print your Ruby objects with style -- in full color and with proper indentation
- better_errors Better error page for Rack apps
- brakeman A static analysis security vulnerability scanner for Ruby on Rails applications
- bullet Help to kill N+1 queries and unused eager loading
- bundler-audit Patch-level verification for Bundler
- dotenv-rails A Ruby gem to load environment variables from
.env
- guard Guard is a command line tool to easily handle events on file system modifications
- pry-rails A runtime developer console and IRB alternative with powerful introspection capabilities
- letter_opener Preview mail in the browser instead of sending
- rubocop A Ruby static code analyzer and formatter, based on the community Ruby style guide
- rubocop-rails A RuboCop extension focused on enforcing Rails best practices and coding conventions
- rubocop-performance An extension of RuboCop focused on code performance checks
Testing Gems
- database_cleaner Strategies for cleaning databases in Ruby. Can be used to ensure a clean state for testing
- rails-controller-testing Brings back
assigns
andassert_template
to your Rails tests - rspec-rails RSpec for Rails-3+
- shoulda-matchers Simple one-liner tests for common Rails functionality
- simplecov Code coverage for Ruby 1.9+ with a powerful configuration library and automatic merging of coverage across test suites
- webmock Library for stubbing and setting expectations on HTTP requests in Ruby
- A much-improved
bin/setup
script - Log rotation so that development and test Rails logs don’t grow out of control