Rails + Hotwire Base is a boilerplate project for full-stack Rails apps with a modern SPA-like experience. It follows the community best practices in terms of standards, security and maintainability, integrating a variety of testing and code quality tools. It's based on Rails 6 and Ruby 3.0.
Finally, it contains a plug and play Administration console (thanks to ActiveAdmin).
This template comes with:
- Schema
- Users table
- Admin users table
- Endpoints
- Sign up with user credentials
- Sign in with user credentials
- Sign out
- Reset password
- Show and update user profile
- Administration panel for users
- Rspec tests
- Code quality tools
- Docker support
- Clone this repo
- Install PostgreSQL in case you don't have it
- Run
bootstrap.sh
with the name of your your project like./bootstrap.sh my_awesome_project
rspec
and make sure all tests passrails s
- You can now try your app!
- Have
docker
anddocker-compose
installed (You can check this by doingdocker -v
anddocker-compose -v
) - Modify the following lines in the
database.yml
file:
default: &default
adapter: postgresql
encoding: unicode
pool: 5
username: postgres
password: postgres
host: db
port: 5432
- Generate a secret key for the app by running
docker-compose run --rm --entrypoint="" web rake secret
, copy it and add it in your environment variables. - Run
docker-compose run --rm --entrypoint="" web rails db:create db:migrate
.- (Optional) Seed the database with an AdminUser for use with ActiveAdmin by running
docker-compose run --rm --entrypoint="" web rails db:seed
. The credentials for this user are: email:[email protected]
; password:password
.
- (Optional) Seed the database with an AdminUser for use with ActiveAdmin by running
- (Optional) If you want to deny access to the database from outside of the
docker-compose
network, remove theports
key in thedocker-compose.yml
from thedb
service. - (Optional) Run the tests to make sure everything is working with:
docker-compose run --rm --entrypoint="" web rspec .
. - Run the application with
docker-compose up
. - You can now try your app!
- ActiveAdmin for easy administration
- Annotate for doc the schema in the classes
- Better Errors for a better error page
- Brakeman for static analysis security
- Bullet help to kill N+1
- DelayedJob for background processing
- Devise for basic auth
- Dotenv for handling environment variables
- Draper for decorators
- Factory Bot for testing data
- Faker for generating test data
- Flipper for feature flags
- Letter Opener for previewing a mail in the browser
- Omniauth Google Oauth2 for Google Sign Up/Sign in
- Pagy for pagination
- Pry for enhancing the ruby shell
- Puma for the server
- Pundit for authorization management
- Rails Best Practices for rails linting
- Reek for ruby linting
- RSpec for testing
- Rubocop for ruby linting
- Shoulda Matchers adds other testing matchers
- Simplecov for code coverage
- Webmock for stubbing http requests
- YAAF for form objects
- Set your mail sender in
config/initializers/devise.rb
- Config your timezone accordingly in
application.rb
.
Turbo Streams uses Action Cable to deliver asynchronous updates to subscribers. This feature allows the user to receive live updates through websockets.
Action Cable relies on redis
as subscription adapter for production environment.
With just a little configuration you can make it work.
# config/cable.yml
production:
adapter: redis
url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
With rails code_analysis
you can run the code analysis tool, you can omit rules with:
- Rubocop Edit
.rubocop.yml
- Reek Edit
.reek.yml
- Rails Best Practices Edit
config/rails_best_practices.yml
- Brakeman Run
brakeman -I
to generateconfig/brakeman.ignore
- Bullet You can add exceptions to a bullet initializer or in the controller
- After adding the project to CC, go to
Repo Settings
- On the
Test Coverage
tab, copy theTest Reporter ID
- Set the current value of
CC_TEST_REPORTER_ID
in the CI project env variables
You can use CODEOWNERS file to define individuals or teams that are responsible for code in the repository.
Code owners are automatically requested for review when someone opens a pull request that modifies code that they own.
Rails + Hotwire Base is maintained by Rootstrap with the help of our contributors.