Tony Ennis
April 15, 2024
Tonic Rails Docs
  • This has now been replaced by H1 Rails & the H1 Rails docs

  • Intro

    • Tonic Rails is our boilerplate for building simple, maintainable Rails applications. It's designed to optimize for 1. Developer Momentum and 2. Contributor Friendliness.

    • Please read Friendly Rails Guidelines and How We Do... before continuing - they explain several of the patterns you'll find here.

  • Setup

    • bundle install

    • rails db:create

    • rails db:migrate

    • rails db:seed

    • Set the app name config/application.rb and /app/helpers/application_helper.rb

    • Update the favicon.

    • Set the default colors in /public/stylesheets/styles.css

    • Configure Postmark

    • Configure ActiveStorage

    • Configure Sentry

  • Notes

    • CSS & JS - We use static tailwind and mini.js as our frontend primitive libraries. 90% of the things we'll need to do on the frontend can be done using them.

    • Admin - We use Active Admin. It's one of the older admin gems, but it has incredible documentation, is still actively supported, and can almost always do what's needed.

    • User Accounts: We use devise for supporting sign in, sign up, forgot password, and other account related functionality.

    • Message Templates - We've added a database model, admin section, and mailer for storing and sending message content.

    • Background Jobs - We use the delayed gem. See also How We Do Delayed Jobs and Scheduling using Delayed Jobs

    • Storing Files - We use ActiveStorage, with Digital Ocean spaces as the default adapter.

    • Versioning - We use Paper Trail

    • Devise - We use custom controllers and custom views to have better control.

    • Devise - We set config.sign_out_via to :get and config.sign_out_all_scopes to false

    • API - The repo includes the endpoints for an API to complement Tonic Expo - our React Native codebase.

  • Patterns

  • Structure

    • views/layouts/application.html.erb houses the base layout

    • views/shared/head loads the content for every page's <head> tag.

    • views/shared/partial_containers.html.erb loads the containers for toasts, modals, and the sidebar. It's loaded just after the opening body tag.

    • /public/stylesheets/styles.css is the primary stylesheet for the customer screens, and is also loaded in to Active Admin, It contains the base css, including

      • Color variables

      • Some reusable utilities e.g. shimmer

      • Default styling for forms and prose text.

    • /public/js/custom.js defines app-wide javascript behaviour, such as tippy.js for tooltips.

    • /public/vendor/... contains any external css or js libraries.


  • Website Page