Rails Template

This is a base Ruby on Rails repository configured for learning with Codespaces (and Gitpod).

  • Ruby version: 3.2.1
  • Rails version: 7.1.3.3

We've added additional Ruby gems and other software that aren't automatically available in a new Rails app, and configured

UJS and Turbo

In Rails version 7, support for Unobtrusive JavaScript (UJS) is not the default. Rather, this has been replaced with Turbo.

However, in AppDev, we typically want to first demonstrate UJS and then enable Turbo manually when we want it.

Therefore, UJS has been pre-configured here with these steps:

  • Pin UJS + jQuery in config/importmap.rb by running:

    % ./bin/importmap pin @rails/ujs
    % ./bin/importmap pin jquery
    
  • Add UJS + jQuery via:

    // app/javascript/application.js
    import jquery from "jquery";
    window.jQuery = jquery;
    window.$ = jquery;
    import Rails from "@rails/ujs"
    Rails.start();

UJS and Turbo can co-exist side-by-side with these instructions, which we already implemented here.

By default, Turbo is disabled via:

// app/javascript/application.js
import { Turbo } from "@hotwired/turbo-rails"
Turbo.session.drive = false

Set it to true to enable Turbo everywhere, or you can use data-turbo="true" to enable Drive on a per-element basis while leaving it globally false.

Additional gems:

Additional software:

  • OS Ubuntu 20.04.5 LTS
  • Chromedriver
  • Fly.io's flyctl
  • Google Chrome (headless browser)
  • Graphviz
  • Node JS 18
  • NPM 8.19.3
  • Postgresql 12
  • Redis
  • Yarn

VS Code extensions:

  • vortizhe.simple-ruby-erb
  • mbessey.vscode-rufo
  • aliariff.vscode-erb-beautify
  • eamodio.gitlens
  • setobiralo.erb-commenter