This is how I setup my Rails 7 projects.
This template currently works with:
- Rails 7.1.x
- Bundler 2.x
- PostgreSQL
- chromedriver
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/EGiataganas/rails_template/main/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/EGiataganas/rails_template/main/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
- Utilities
- Security
- brakeman and bundler-audit – detect security vulnerabilities
- Testing
- capybara – shortcuts for common ActiveRecord tests
- factory_bot_rails - fixtures replacement
- pry-byebug - debugging
- rspec-rails - testing framework
- selenium-webdriver - writing automated tests