Rails Playground

A Rails playground for testing stimulus, javascript and new rails features like turbo-rails, actiontext and more.

The stack for this application
  • rails 7.0

  • jssbundling-rails with esbuild

  • cssbundling-rails

  • Bootstrap 5.x

  • simple_form

Have fun. If you find a bug or something to improve, open an issue or create a pull request.

Rails Playground is just a collection of techniques. If you are searching for a complete tutorial with Rails 7 and Hotwire/Turbo, have a look at https://www.hotrails.dev/

Installation

Clone the repository
git clone https://github.com/swobspace/rails-playground.git
Change into the directory rails-playground and install dependencies
cd rails-playground
bundle && yarn
Run the database migration and fill database with some test data
bin/rake db:migrate
bin/rake db:seed

If you want to change the number of generated records, change db/seeds.rb to your needs. Default is 100. You can simple run bin/rake db:seed multiple times to get a multiple of 100 data sets.

Start the webserver
bin/dev

Available Examples

Category Description

Datatables

Using a single stimulus controller for 3 different scenarios: html tables with and without buttons and for tables with server side processing (fetching data via ajax)

Flash/Alert

Use turbo_stream to show flash messages as Bootstrap Alert and remove it after some animation.

Flash/Toast

Use turbo_stream to show flash messages as Bootstrap Toast using default options (animation: true, autohide: true, delay: 5000)

Modal

Get Bootstrap v5 Modal playing nice with turbo_stream.

Sortable

A sortable list with Bootstrap list group and @shopify/draggable.js using turbo_stream for updates after sorting.