The great thing about working with a framework like Ruby on Rails is how you can pick and choose the components that make up your application. Developers often have preferences concerning solutions or tools they use in their projects. They have the choice of testing tools such as Rspec or Cucumber, testing factory libraries such as FactoryBot or Fabrication, authentication solutions such as Devise or AuthLogic, and authorization solutions such as CanCan or Pundit.
It can feel heavy having to reconfigure a freshly generated Rails application to use these different components, because you spend most of your time configuring the new application rather than jumping into actually building the functionality.
Thankfully Rails supports Application Templates that make configuring a new application a breeze.
It’s possible for you to configure your own custom template with your primary preferences all in one file. You could maintain your own template in a Github Gist using this option.
See my example template.
App Template Command
Even better than this is that you can choose to apply certain configurations to your application ala carte by using the ‘app:template’ rails command. This command allows you to run template fragments from publicly hosted template scripts. You can find many scripts for various solutions on Rails Bytes.
Because I use Webpack as my asset pipeline for the front-end application and assets, I don’t need the Rails asset-pipeline or page rendering helpers. This causes me to prefer using an API-only configuration with Ruby on Rails.
rails new my_application --api --webpack=vue
After I’m done generating the application, I use the following application templates to setup my app.
- EditorConfig - Specifies file formatting guidelines for many code editors
- Rspec - Popular unit testing framework for Ruby
- FactoryBot - Fixtures replacement for testing
- StandardRB - Ruby style guide, linter, and formatter. See StandardRB
- dotenv - A Ruby gem to load environment variables from
.env. See dotenv-rails
Here are some optional recommendations that depend on the type of application you are developing:
- Friendly ID - “Swiss Army bulldozer” of slugging and permalink plugins for Ruby on Rails. See friendly_id
- PgHero - Performance Dashboard for PostgreSQL. See PgHero
- Pundit - Authorization system. See Pundit
- Vue with InertiaJS - Library supporting conventional interface between front-end tools (React, Vue.js, and Svelte) and back-end (Laravel and Rails). See InertiaJs
- SendGrid - Configures Ruby support for SendGrid email service API
- GraphQL - Add a GraphQL API to your Rails app
- DelayedJob - Background Job processing. See DelayedJob
- Sidekiq - Background Job processing. See Sidekiq