switch to turbo

This commit is contained in:
Ben Harris 2021-08-27 00:40:47 -04:00
parent 54901541e3
commit 68f5f71701
9 changed files with 30 additions and 14 deletions

View File

@ -13,12 +13,12 @@ gem 'puma', '~> 5.4'
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 5.4'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# https://github.com/hotwired/turbo-rails
gem 'turbo-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.11'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

View File

@ -147,6 +147,7 @@ GEM
rb-fsevent (0.11.0)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis (4.4.0)
regexp_parser (2.1.1)
rubyzip (2.3.2)
sass-rails (6.0.0)
@ -177,9 +178,8 @@ GEM
sqlite3 (1.4.2)
thor (1.1.0)
tilt (2.0.10)
turbolinks (5.2.1)
turbolinks-source (~> 5.2)
turbolinks-source (5.2.0)
turbo-rails (0.7.4)
rails (>= 6.0.0)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
web-console (4.1.0)
@ -211,12 +211,13 @@ DEPENDENCIES
pry-rails
puma (~> 5.4)
rails (~> 6.1.4, >= 6.0.3.7)
redis (~> 4.0)
sass-rails (>= 6)
selenium-webdriver
spring
spring-watcher-listen (~> 2.0.0)
sqlite3 (~> 1.4)
turbolinks (~> 5)
turbo-rails
tzinfo-data
web-console (>= 4.1.0)
webpacker (~> 5.4)

View File

@ -6,14 +6,14 @@ class PagesController < ApplicationController
def teampicker
@groups = maketeams
@machines = Machine.limit(@groups.count).order(Arel.sql("RANDOM()"))
@machines = Machine.limit(@groups.size).order(Arel.sql("RANDOM()"))
end
private
def maketeams
r = Player.where("strikes < 4").order(Arel.sql("RANDOM()")).to_a
groups = case r.count
groups = case r.size
when 5
[r.shift(3), r.shift(2)]
when 6

View File

@ -4,7 +4,6 @@
// that code so it'll be compiled.
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
@ -15,3 +14,5 @@ require("channels")
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
import "@hotwired/turbo-rails"

View File

@ -1,6 +1,6 @@
<h1>Pinball Machines</h1>
<p><%= @machines.count %> available machines</p>
<p><%= @machines.size %> available machines</p>
<ul>
<% @machines.each do |machine| %>
<li>

View File

@ -1,6 +1,6 @@
<h1>Pinball Players</h1>
<p><%= @players.count %> available players</p>
<p><%= @players.size %> available players</p>
<ul>
<% @players.each do |player| %>
<li>

View File

@ -1,5 +1,6 @@
development:
adapter: async
adapter: redis
url: redis://localhost:6379/1
test:
adapter: test

View File

@ -2,11 +2,11 @@
"name": "pinrails",
"private": true,
"dependencies": {
"@hotwired/turbo-rails": "^7.0.0-rc.1",
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "5.4.2",
"turbolinks": "^5.2.0",
"webpack": "^4.46.0",
"webpack-cli": "^3.3.12"
},

View File

@ -885,6 +885,19 @@
resolved "https://registry.yarnpkg.com/@csstools/convert-colors/-/convert-colors-1.4.0.tgz#ad495dc41b12e75d588c6db8b9834f08fa131eb7"
integrity sha512-5a6wqoJV/xEdbRNKVo6I4hO3VjyDq//8q2f9I6PBAvMesJHFauXDorcNCsr9RzvsZnaWi5NYCcfyqP1QeFHFbw==
"@hotwired/turbo-rails@^7.0.0-rc.1":
version "7.0.0-rc.1"
resolved "https://registry.yarnpkg.com/@hotwired/turbo-rails/-/turbo-rails-7.0.0-rc.1.tgz#68cc07b2a1e7d9b29240c525c657722b3f0c3842"
integrity sha512-LLOgtHWb/cnz0bXlfJ9khWHapQuCOuUI48yiSVgL3veklvbX1vyQlk/ALn35Z6nHTi7Bf+MHMS9H5W2c/vwKuw==
dependencies:
"@hotwired/turbo" "^7.0.0-rc.1"
"@rails/actioncable" "^6.0.0"
"@hotwired/turbo@^7.0.0-rc.1":
version "7.0.0-rc.1"
resolved "https://registry.yarnpkg.com/@hotwired/turbo/-/turbo-7.0.0-rc.1.tgz#a5c1be86def1cc39b3011c935c5734b8632af5c3"
integrity sha512-niNA68ku4TZYbV3biwTPf1L5CidP50S2xfeb5rGQfodvPB9UAtkqKFFRIA0LL8y0DG4MGIZ/QFlbvlmFea5p4w==
"@nodelib/fs.scandir@2.1.5":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"