This is a template for new Rails projects. It includes several helpful gems and configurations to get you started quickly.
- Clone this repository
- Delete the
.git
folder - Initialize a new git repository:
git init
- Rename the project in
config/application.rb
- Update
config/database.yml
with your database credentials if needed - Run
bundle install
- Run
rails db:create db:migrate
This project is configured to run in Docker containers. You can choose which services to include.
For the first time setup or when you want to change the included services:
chmod +x docker-compose-up.sh
./docker-compose-up.sh
This script will prompt you to choose which services you want to include (Redis and/or Sidekiq).
After the initial setup, you can use the quick start script to launch Docker with your saved configuration:
chmod +x docker-compose-quickstart.sh
./docker-compose-quickstart.sh
If you prefer to manually configure your Docker setup or your project requirements have changed:
-
Edit the
docker-compose.yml
file directly to include or exclude services. -
Launch Docker with:
docker-compose up
- RSpec for testing
- FactoryBot for test data
- Faker for generating fake data
- Rubocop for code style checking
- (list other significant gems here)
- MySQL database
- RSpec test framework
- Tailwind CSS
- Docker setup with optional Redis and Sidekiq
Describe here how to use any custom scripts or features you've added to the template.
After running bundle install
, follow these steps to set up and configure the gems:
-
RSpec Rails
rails generate rspec:install
This will create the necessary configuration files for RSpec.
-
Factory Bot Rails Add the following to
spec/rails_helper.rb
:RSpec.configure do |config| config.include FactoryBot::Syntax::Methods end
-
Shoulda Matchers Add the following to
spec/rails_helper.rb
:Shoulda::Matchers.configure do |config| config.integrate do |with| with.test_framework :rspec with.library :rails end end
-
Database Cleaner (if you decide to add it) Add the following to
spec/rails_helper.rb
:RSpec.configure do |config| config.before(:suite) do DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) end config.around(:each) do |example| DatabaseCleaner.cleaning do example.run end end end
-
Bullet Add the following to
config/environments/development.rb
:config.after_initialize do Bullet.enable = true Bullet.alert = true Bullet.bullet_logger = true Bullet.console = true Bullet.rails_logger = true Bullet.add_footer = true end
-
Annotate Run the following command to add annotations to your models:
rails g annotate:install
-
Rubocop Create a
.rubocop.yml
file in your project root and add your preferred rules. -
Brakeman You can run Brakeman manually with:
brakeman
-
Rails ERD To generate your first ERD, run:
rake erd
-
Pry Rails No additional setup needed. It will automatically replace IRB in the Rails console.
-
Better Errors No additional setup needed for development. It will automatically provide improved error pages.
-
Rack Mini Profiler It should work out of the box, but you can customize it by creating an initializer:
bundle exec rails g rack_mini_profiler:install
-
Acts As Paranoid No initial setup needed. You can use it in your models like this:
class YourModel < ApplicationRecord acts_as_paranoid end
Remember to restart your Rails server after making these changes to ensure all new configurations are loaded.