Rails Starter Template screenshot

Rails Starter Template

Updated: 8 Jun 2024
51 Stars

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

Categories

Overview:

The Rails Starter Template is an opinionated Rails setup that utilizes Rails 7, PostgreSQL, TailwindCSS, Stimulus, Hotwire, and RSpec. It includes a Node-based setup for bundling JavaScript and CSS with jsbundling-rails and cssbundling-rails. There is also an option to use Propshaft as the asset pipeline instead of Sprockets. The template requires several dependencies to be installed, including Ruby, Node, Bundler, Yarn, Overmind, PostgreSQL, Redis, and optionally Docker.

Features:

  • Rails 7
  • PostgreSQL
  • TailwindCSS
  • Stimulus
  • Hotwire
  • RSpec
  • Node-based JavaScript and CSS bundling
  • Propshaft or Sprockets asset pipeline

Installation:

  1. Install Ruby version 3: asdf install ruby
  2. Install Node version 19: asdf install node
  3. Install Bundler: gem install bundler
  4. Install Yarn: brew install yarn
  5. Install Overmind: brew install tmux overmind
  6. Install PostgreSQL and start it: brew install postgresql and brew services start postgresql
  7. Install Redis and start it: brew install redis and brew services start redis
  8. Additional Homebrew dependencies can be installed by running:
brew bundle
  1. Optional: Install Docker to use with the preconfigured dip.yml for a dockerized dev environment using dip

Getting Started:

  1. Run the setup script to install all necessary gems and packages, prepare the database, and perform other setup steps for the application.

Provisioning and Interacting with Docker and dip:

  • Ensure that Docker and docker-compose are installed (for MacOS, use the official app).
  • Use the dip CLI, a utility CLI tool for provisioning and interacting with applications configured by docker-compose.
  • Refer to the dip.yml file for available commands.

Development:

  • Run Overmind (or Foreman if Overmind is not installed), automatically build all assets, and start the Rails server and Sidekiq.

Code Guidelines:

  • Use StandardRB for Ruby to automatically fix code style offenses.
  • To automatically format Ruby with StandardRB, run:
standardrb --fix
  • Use StandardJS for JavaScript code formatting.
  • To automatically format JavaScript with StandardJS, run:
standardjs --fix

Running the Specs:

  • To run all the specs, run:
rspec
  • Alternatively, individual spec files can be run using the RSpec command.

  • Inside the docker container, there are two different commands to run unit tests and system specs respectively.

Summary:

The Rails Starter Template is a preconfigured Rails setup that includes popular frameworks and libraries such as TailwindCSS, Stimulus, and RSpec. It offers the option to use either Propshaft or Sprockets for asset bundling and includes guidelines for code formatting using StandardRB for Ruby and StandardJS for JavaScript. The template requires several dependencies to be installed and provides a setup script for easy installation and configuration. Additionally, Docker and the dip CLI tool can be used for a dockerized development environment.