{"id":13704889,"url":"https://github.com/mattbrictson/rails-template","last_synced_at":"2026-01-10T19:06:19.486Z","repository":{"id":26637315,"uuid":"30093164","full_name":"mattbrictson/rails-template","owner":"mattbrictson","description":"My former app template for Rails 7. All recommendations you see here have been moved to https://github.com/mattbrictson/nextgen","archived":true,"fork":false,"pushed_at":"2023-12-18T20:07:18.000Z","size":645,"stargazers_count":1076,"open_issues_count":0,"forks_count":240,"subscribers_count":36,"default_branch":"main","last_synced_at":"2024-02-15T09:35:48.518Z","etag":null,"topics":["boilerplate","heroku","rails","rails-generators","vite"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mattbrictson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-01-30T22:17:11.000Z","updated_at":"2024-01-30T21:36:43.000Z","dependencies_parsed_at":"2023-10-12T06:08:32.244Z","dependency_job_id":"3c56e388-4c67-4a52-834b-eb1421d6f454","html_url":"https://github.com/mattbrictson/rails-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattbrictson%2Frails-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattbrictson%2Frails-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattbrictson%2Frails-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mattbrictson%2Frails-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mattbrictson","download_url":"https://codeload.github.com/mattbrictson/rails-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234575214,"owners_count":18854924,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boilerplate","heroku","rails","rails-generators","vite"],"created_at":"2024-08-02T22:00:22.918Z","updated_at":"2025-09-28T23:32:25.810Z","avatar_url":"https://github.com/mattbrictson.png","language":"Ruby","funding_links":[],"categories":["Ruby","Happy Exploring 🤘","Starters/Boilerplates"],"sub_categories":["Articles"],"readme":"📣 **I am no longer maintaining this project. Please check out [mattbrictson/nextgen](https://github.com/mattbrictson/nextgen) instead.** Nextgen includes all the recommendations you see here, but in a new interactive format that lets you pick and choose the enhancements appropriate to your app. [Try it and send me your feedback!](https://github.com/mattbrictson/nextgen)\n\n---\n\n# mattbrictson/rails-template\n\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mattbrictson/rails-template/ci.yml)](https://github.com/mattbrictson/rails-template/actions/workflows/ci.yml)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mattbrictson/rails-template/ci-vite.yml?label=vite+build)](https://github.com/mattbrictson/rails-template/actions/workflows/ci-vite.yml)\n\n\n## About\n\nThis is the application template that I recommend for Rails 7 projects. I've assembled this template over the years to include best-practices, tweaks, documentation, and personal preferences, while still generally adhering to the \"Rails way\".\n\nI've written several blog posts on techniques, helpers, and boilerplate that are included in this template, if you'd like to take a deeper dive:\n\n- [How to organize CSS in a Rails project](https://mattbrictson.com/blog/organizing-css-in-rails)\n- [Tips for writing Rails tasks with Thor instead of Rake](https://mattbrictson.com/blog/rails-tasks-with-thor)\n- [Speed up your default Rake task with the multitask `-m` option](https://mattbrictson.com/blog/rake-multitask)\n- [Automatically open the browser when the Rails server starts](https://mattbrictson.com/blog/open-browser-on-rails-start)\n- [Configuring RuboCop to scan the right files in a Rails project](https://mattbrictson.com/blog/including-and-excluding-files-in-rubocop)\n- [Easier Nested Layouts in Rails](https://mattbrictson.com/blog/easier-nested-layouts-in-rails)\n- [Fixing slow, flaky system tests in Vite-Rails](https://mattbrictson.com/blog/faster-vite-test-without-autobuild)\n- [The 3 Vite plugins I use on every new Rails project](https://mattbrictson.com/blog/3-vite-rails-plugins)\n- [Inline SVGs with Rails and Vite](https://mattbrictson.com/blog/inline-svg-with-vite-rails)\n\n## Requirements\n\nThis template currently requires:\n\n* **Rails 7.1**\n* **Ruby 3.1 or newer**\n* PostgreSQL\n* Node 16.14+ or 18+, and Yarn 1.x\n\nFor older versions of Rails, you can use one of [these branches](https://github.com/mattbrictson/rails-template/branches/all) going back all the way to Rails 4.2.\n\n## Installation\n\n*Optional.*\n\nTo make this the default Rails application template on your system, create a `~/.railsrc` file with these contents:\n\n```\n-d postgresql\n-m https://raw.githubusercontent.com/mattbrictson/rails-template/main/template.rb\n```\n\n## Usage\n\nThis template assumes you will store your project in a remote git repository (e.g. 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:\n\n1. The git URL of your (freshly created and empty) GitHub repository\n2. The hostname of your production server\n\nTo generate a Rails application using this template, pass the `-m` option to `rails new`, like this:\n\n```\nrails new blog \\\n  -d postgresql \\\n  -m https://raw.githubusercontent.com/mattbrictson/rails-template/main/template.rb\n```\n\n*Remember that options must go after the name of the application.* The only database supported by this template is `postgresql`.\n\nIf you’ve installed this template as your default (using `~/.railsrc` as described above), then all you have to do is run:\n\n```\nrails new blog\n```\n\n## What does it do?\n\nThe template will perform the following steps:\n\n1. Generate your application files and directories\n2. Create the development and test databases\n3. Commit everything to git\n4. Push the project to the remote git repository you specified\n\n## What is included?\n\n#### Optional support for `vite_rails`⚡️\n\nAdd the `--javascript vite` option to the `rails new` command to get started with Vite! [Vite][vite] is an easy to use alternative to Webpack(er), and much more powerful than the standard import map and css/jsbundling-rails options that are built into Rails.\n\n- Frontend code (JS, CSS, images) will be placed in `app/frontend/`\n- Run `yarn start` to start the development server with hot reloading\n- Plain CSS with [modern-normalize](https://github.com/sindresorhus/modern-normalize) will be used for styles (the `--css` option will be ignored)\n\nIf you don't specify `--javascript vite`, then this template will use the standard Rails 7 behavior.\n\n#### These gems are added to the standard Rails stack\n\n* Core\n    * [sidekiq][] – Redis-based job queue implementation for Active Job\n* Configuration\n    * [dotenv][] – for local configuration\n* Utilities\n    * [annotate][] – auto-generates schema documentation\n    * [good_migrations][] - prevents app models from being improperly referenced in migrations\n* Linting\n    * [rubocop][] – enforces Ruby code style\n    * [erblint][] – applies rubocop rules within html.erb files\n    * [stylelint][] – checks (S)CSS files\n    * [eslint][] – checks JS/TS files\n* Security\n    * [brakeman][] and [bundler-audit][] – detect security vulnerabilities\n* Testing\n    * [capybara-lockstep][] – for more reliable browser testing\n    * [factory_bot_rails][] – for easy setup of test data\n    * [shoulda][] – shortcuts for common ActiveRecord tests\n\n#### Postmark\n\nI like to use [Postmark][] for transactional email, and so I've included the [postmark-rails][] gem and configured it in `environments/production.rb`. Make sure to sign up for a Postmark account to get an API key, or switch to your own preferred email provider before deploying your app.\n\n#### Other tweaks that patch over some Rails shortcomings\n\n* A much-improved `bin/setup` script\n\n## How does it work?\n\nThis 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.\n\nNormally, Rails only allows a single file to be specified as an application template (i.e. using the `-m \u003cURL\u003e` 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.\n\nThis 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.\n\nRails 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][thor] to learn more.\n\n[sidekiq]:http://sidekiq.org\n[dotenv]:https://github.com/bkeepers/dotenv\n[annotate]:https://github.com/ctran/annotate_models\n[rubocop]:https://github.com/bbatsov/rubocop\n[erblint]:https://github.com/Shopify/erb-lint\n[factory_bot_rails]:https://github.com/thoughtbot/factory_bot_rails\n[Postmark]:http://postmarkapp.com\n[postmark-rails]:http://www.rubydoc.info/gems/postmark-rails/0.12.0\n[brakeman]:https://github.com/presidentbeef/brakeman\n[bundler-audit]:https://github.com/rubysec/bundler-audit\n[shoulda]:https://github.com/thoughtbot/shoulda\n[application templates]:http://guides.rubyonrails.org/generators.html#application-templates\n[template.rb]: template.rb\n[thor]: https://github.com/rails/thor\n[vite]: https://vite-ruby.netlify.app\n[good_migrations]: https://github.com/testdouble/good-migrations\n[capybara-lockstep]: https://github.com/makandra/capybara-lockstep\n[eslint]: https://eslint.org\n[stylelint]: https://stylelint.io\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattbrictson%2Frails-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmattbrictson%2Frails-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmattbrictson%2Frails-template/lists"}