This is a Rails Application Template that based on https://github.com/davetron5000/rails-app-template-sustainable This is for Rails 6.1 only!
bin/rails new my-app --api \
--skip-bundle \
--skip-turbolinks \
--skip-sprockets \
--skip-spring \
--skip-listen \
--skip-action-cable \
--database=postgresql \
--template=https://raw.githubusercontent.com/mkhoa1412/rails-api-template/master/template.rb
git clone https://github.com/mkhoa1412/rails-api-template
rails new my-app --api \
--rc=rails-api-template/.railsrc \
--template=rails-api-template/template.rb
In particular:
- Gems:
- Removes Gems that cause problems:
- Turbolinks makes your app feel slow and broken
- Spring creates an unstable development environment
- Gems for better testing:
- Factory Bot to manage test data
- Faker to provide fake values for that data
- minitest-reporters to get more useful test run output
- Gems for development:
- dotenv-rails to allow management of local UNIX environments
- foreman to run multiple processes locally
- Gems for managing security issues:
- Brakeman
- bundler-audit
- Gems for better production behavior:
- lograge for single-line logging
- sidekiq for background jobs
- Postgres
- Removes Gems that cause problems:
- Dev Workflow
bin/setup
that does a more involved setupbin/ci
runs all quality checks (tests, brakeman, bundle audit, yarn audit)bin/run
runs the app locallybin/sql
get a SQL prompt to your local databasebin/db-{migrate,rollback}
- migrate and rollback both dev and test in one commandbin/release
- Release phase script for Heroku to run migrations
- Other Things
- Removes
config/database.yml
andconfig/secrets.yml
because your app will get all configuration fromENV
- SQL-based schema management so you can use any feature of Postgres you like
- No stylesheets or helpers generated by generators since they provide a false sense of modularity that is of zero benefit.
- A simple base
ApplicationService
and a service class generatorbin/rails g service MyThing
to encourage putting code inapp/services
- All
datetime
fields in migrations usestimestamp with time zone
which is the proper type in Postgres. - A method
confidence_check
to allow validating assumptions in tests separate from asserting code behavior. - A method
not_implemented!
to allow skipping a test you have not implemented - A test to lint all your factories
- Removes