Skip to content

peterberkenbosch/rails-starter-template

Repository files navigation

Rails starter template

IN MAINTENANCE MODE

In the last couple of months the Rails landscape changed, and so did my opinionated Rails setup. I will keep this one as maintained as possible, but currently running on edge Rails with just minor changes. Those specifics will be open sourced in the future as well.

Opinionated Rails setup using Rails 7, PostgreSQL, TailwindCSS, Stimulus, Hotwire and RSpec.

We are bundling JavaScript and CSS through a Node-based setup with jsbundling-rails and cssbundling-rails.

If you want to run propshaft as the asset pipeline you can use this branch: https://github.com/peterberkenbosch/rails-starter-template/tree/propshaft. The main branch will be using Sprockets for the time being.

You need the following installed:

  • Ruby >= 3 (asdf install)
  • Node 19 (asdf install)
  • Bundler (gem install bundler)
  • Yarn (brew install yarn)
  • Overmind (brew install tmux overmind)
  • Postgresql (brew install postgresql start with: brew services start postgresql)
  • Redis (brew install redis start with: brew services start redis)

If you are using asdf (I recommend that you do :) ) you can install the required Ruby and NodeJS versions with asdf install

The Homebrew dependencies can be installed with running:

brew bundle install --no-upgrade

Additional Homebrew dependencies can be added to the Brewfile

Optional: Docker to use with the preconfigured dip.yml to setup a dockerized dev environment using dip

Getting started

Initial application setup

Run the setup script that will run the needed setup steps for the application, installing all gems and packages, database preparing etc.

$ bin/setup

Provisioning and interacting with Docker and dip

You need docker and docker-compose installed (for MacOS just use official app).

This app uses the dip CLI, a utility CLI tool for straightforward provisioning and interactions with applications configured by docker-compose.

$ gem install dip
$ dip provision

Take a look at the dip.yml file for the available commands

Development

Will run Overmind (or Foreman if Overmind is not installed), builds all assets automaticly and will start the rails server and sidekiq

$ bin/dev

When using dip:

$ dip up web

Code Guidelines

It uses StandardRB for Ruby to automatically fix code style offenses.

$ bundle exec standardrb

to automatically format Ruby with StandardRB you can run:

$ bundle exec standardrb --fix

For Javascript we use StandardJS.

$ yarn standard

to automatically format the javascript with StandardJS you can run:

$ yarn standard --fix

Running the specs

Inspired by Evil Martians - System of a Test article

To run all the specs you can run:

$ rake

or use RSpec directly with

$ bundle exec rspec

Inside the docker container we have 2 different commands. To just run the unit tests:

$ dip rspec

and to just run the system specs:

$ dip rspec system

About

Opinionated Rails 7 starter template using esbuild, tailwindcss, postgresql and hotwired tested with RSpec

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published