about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBen Harris <ben@tilde.team>2021-08-27 00:40:47 -0400
committerBen Harris <ben@tilde.team>2021-08-27 00:40:47 -0400
commit68f5f71701f53dffba53b3390b8e01cc23cc3d9c (patch)
treef1facb60eae12c62fc7801a7b793a4cc7c1e3588
parent54901541e35b29fcdc05cf036b1eeb203df7bd7d (diff)
switch to turbo
-rw-r--r--Gemfile6
-rw-r--r--Gemfile.lock9
-rw-r--r--app/controllers/pages_controller.rb4
-rw-r--r--app/javascript/packs/application.js3
-rw-r--r--app/views/machines/index.html.erb2
-rw-r--r--app/views/players/index.html.erb2
-rw-r--r--config/cable.yml3
-rw-r--r--package.json2
-rw-r--r--yarn.lock13
9 files changed, 30 insertions, 14 deletions
diff --git a/Gemfile b/Gemfile
index d20ac2f..8fd2931 100644
--- a/Gemfile
+++ b/Gemfile
@@ -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'
 
diff --git a/Gemfile.lock b/Gemfile.lock
index 3e9b710..171efda 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -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)
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb
index 2c454f9..923edf2 100644
--- a/app/controllers/pages_controller.rb
+++ b/app/controllers/pages_controller.rb
@@ -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
diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js
index 9cd55d4..9e9feba 100644
--- a/app/javascript/packs/application.js
+++ b/app/javascript/packs/application.js
@@ -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"
diff --git a/app/views/machines/index.html.erb b/app/views/machines/index.html.erb
index 21717b9..33e279b 100644
--- a/app/views/machines/index.html.erb
+++ b/app/views/machines/index.html.erb
@@ -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>
diff --git a/app/views/players/index.html.erb b/app/views/players/index.html.erb
index 744e1cd..7ad7944 100644
--- a/app/views/players/index.html.erb
+++ b/app/views/players/index.html.erb
@@ -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>
diff --git a/config/cable.yml b/config/cable.yml
index 2913ab0..f08e5ee 100644
--- a/config/cable.yml
+++ b/config/cable.yml
@@ -1,5 +1,6 @@
 development:
-  adapter: async
+  adapter: redis
+  url: redis://localhost:6379/1
 
 test:
   adapter: test
diff --git a/package.json b/package.json
index 28c7213..5201082 100644
--- a/package.json
+++ b/package.json
@@ -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"
   },
diff --git a/yarn.lock b/yarn.lock
index fe5fb53..d086f29 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -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"