about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBen Harris <ben@tilde.team>2022-01-15 12:32:36 -0500
committerBen Harris <ben@tilde.team>2022-01-15 12:32:36 -0500
commit1d9a622303d7ef6c2f1db99d759554c268767cc4 (patch)
treefa6cdede34fb43efe104ea531bb4c53e04f364e9
parent2c8c227493509175fcdbcba3e6a85f8b954a169e (diff)
remove edit.html.erb
-rw-r--r--app/controllers/machines_controller.rb8
-rw-r--r--app/controllers/players_controller.rb11
-rw-r--r--app/views/layouts/application.html.erb5
-rw-r--r--app/views/machines/_machine.html.erb10
-rw-r--r--app/views/machines/edit.html.erb10
-rw-r--r--app/views/machines/index.html.erb5
-rw-r--r--app/views/machines/show.html.erb3
-rw-r--r--app/views/players/_player.html.erb15
-rw-r--r--app/views/players/edit.html.erb10
-rw-r--r--app/views/players/index.html.erb3
-rw-r--r--app/views/players/show.html.erb3
-rw-r--r--test/controllers/machines_controller_test.rb9
-rw-r--r--test/controllers/players_controller_test.rb9
13 files changed, 24 insertions, 77 deletions
diff --git a/app/controllers/machines_controller.rb b/app/controllers/machines_controller.rb
index d83a52f..3ef5893 100644
--- a/app/controllers/machines_controller.rb
+++ b/app/controllers/machines_controller.rb
@@ -5,7 +5,7 @@ class MachinesController < ApplicationController
 
   # GET /machines or /machines.json
   def index
-    @machines = Machine.all
+    @machines = Machine.order(:name)
   end
 
   # GET /machines/1 or /machines/1.json
@@ -25,7 +25,7 @@ class MachinesController < ApplicationController
 
     respond_to do |format|
       if @machine.save
-        format.html { redirect_to machine_url(@machine), notice: 'Machine was successfully created.' }
+        format.html { redirect_to machines_url, notice: 'Machine was successfully created.' }
         format.json { render :show, status: :created, location: @machine }
       else
         format.html { render :new, status: :unprocessable_entity }
@@ -38,10 +38,10 @@ class MachinesController < ApplicationController
   def update
     respond_to do |format|
       if @machine.update(machine_params)
-        format.html { redirect_to machine_url(@machine), notice: 'Machine was successfully updated.' }
+        format.html { redirect_to machines_url, notice: 'Machine was successfully updated.' }
         format.json { render :show, status: :ok, location: @machine }
       else
-        format.html { render :edit, status: :unprocessable_entity }
+        format.html { render :show, status: :unprocessable_entity }
         format.json { render json: @machine.errors, status: :unprocessable_entity }
       end
     end
diff --git a/app/controllers/players_controller.rb b/app/controllers/players_controller.rb
index c1139e1..44034e5 100644
--- a/app/controllers/players_controller.rb
+++ b/app/controllers/players_controller.rb
@@ -5,7 +5,7 @@ class PlayersController < ApplicationController
 
   # GET /players or /players.json
   def index
-    @players = Player.all
+    @players = Player.order(:name)
   end
 
   # GET /players/1 or /players/1.json
@@ -16,16 +16,13 @@ class PlayersController < ApplicationController
     @player = Player.new
   end
 
-  # GET /players/1/edit
-  def edit; end
-
   # POST /players or /players.json
   def create
     @player = Player.new(player_params)
 
     respond_to do |format|
       if @player.save
-        format.html { redirect_to player_url(@player), notice: 'Player was successfully created.' }
+        format.html { redirect_to players_url, notice: 'Player was successfully created.' }
         format.json { render :show, status: :created, location: @player }
       else
         format.html { render :new, status: :unprocessable_entity }
@@ -38,10 +35,10 @@ class PlayersController < ApplicationController
   def update
     respond_to do |format|
       if @player.update(player_params)
-        format.html { redirect_to player_url(@player), notice: 'Player was successfully updated.' }
+        format.html { redirect_to players_url, notice: 'Player was successfully updated.' }
         format.json { render :show, status: :ok, location: @player }
       else
-        format.html { render :edit, status: :unprocessable_entity }
+        format.html { render :show, status: :unprocessable_entity }
         format.json { render json: @player.errors, status: :unprocessable_entity }
       end
     end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 665f897..a21e612 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -11,6 +11,11 @@
   </head>
 
   <body>
+    <nav>
+      <%= link_to "Pins", machines_url %>
+      <%= link_to "Players", players_url %>
+    </nav>
+
     <%= yield %>
   </body>
 </html>
diff --git a/app/views/machines/_machine.html.erb b/app/views/machines/_machine.html.erb
index edba53e..c506363 100644
--- a/app/views/machines/_machine.html.erb
+++ b/app/views/machines/_machine.html.erb
@@ -1,12 +1,6 @@
 <div id="<%= dom_id machine %>">
   <p>
-    <strong>Name:</strong>
-    <%= machine.name %>
+    <%= link_to machine.name, machine %>
+    <small><%= machine.edition %></small>
   </p>
-
-  <p>
-    <strong>Edition:</strong>
-    <%= machine.edition %>
-  </p>
-
 </div>
diff --git a/app/views/machines/edit.html.erb b/app/views/machines/edit.html.erb
deleted file mode 100644
index a390477..0000000
--- a/app/views/machines/edit.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-<h1>Editing machine</h1>
-
-<%= render "form", machine: @machine %>
-
-<br>
-
-<div>
-  <%= link_to "Show this machine", @machine %> |
-  <%= link_to "Back to machines", machines_path %>
-</div>
diff --git a/app/views/machines/index.html.erb b/app/views/machines/index.html.erb
index b5e2c85..2c99524 100644
--- a/app/views/machines/index.html.erb
+++ b/app/views/machines/index.html.erb
@@ -1,13 +1,10 @@
 <p style="color: green"><%= notice %></p>
 
-<h1>Machines</h1>
+<h1>Pins</h1>
 
 <div id="machines">
   <% @machines.each do |machine| %>
     <%= render machine %>
-    <p>
-      <%= link_to "Show this machine", machine %>
-    </p>
   <% end %>
 </div>
 
diff --git a/app/views/machines/show.html.erb b/app/views/machines/show.html.erb
index 1af79f9..7870783 100644
--- a/app/views/machines/show.html.erb
+++ b/app/views/machines/show.html.erb
@@ -1,9 +1,8 @@
 <p style="color: green"><%= notice %></p>
 
-<%= render @machine %>
+<%= render "form", machine: @machine %>
 
 <div>
-  <%= link_to "Edit this machine", edit_machine_path(@machine) %> |
   <%= link_to "Back to machines", machines_path %>
 
   <%= button_to "Destroy this machine", @machine, method: :delete %>
diff --git a/app/views/players/_player.html.erb b/app/views/players/_player.html.erb
index 35e7cb1..4d1abeb 100644
--- a/app/views/players/_player.html.erb
+++ b/app/views/players/_player.html.erb
@@ -1,17 +1,6 @@
 <div id="<%= dom_id player %>">
   <p>
-    <strong>Name:</strong>
-    <%= player.name %>
+    <% if player.paid %>✓<% else %>&nbsp;<% end %>
+    <%= link_to player.name, player %>
   </p>
-
-  <p>
-    <strong>Paid:</strong>
-    <%= player.paid %>
-  </p>
-
-  <p>
-    <strong>Strikes:</strong>
-    <%= player.strikes %>
-  </p>
-
 </div>
diff --git a/app/views/players/edit.html.erb b/app/views/players/edit.html.erb
deleted file mode 100644
index a6cea2b..0000000
--- a/app/views/players/edit.html.erb
+++ /dev/null
@@ -1,10 +0,0 @@
-<h1>Editing player</h1>
-
-<%= render "form", player: @player %>
-
-<br>
-
-<div>
-  <%= link_to "Show this player", @player %> |
-  <%= link_to "Back to players", players_path %>
-</div>
diff --git a/app/views/players/index.html.erb b/app/views/players/index.html.erb
index eac7710..5a2b9ef 100644
--- a/app/views/players/index.html.erb
+++ b/app/views/players/index.html.erb
@@ -5,9 +5,6 @@
 <div id="players">
   <% @players.each do |player| %>
     <%= render player %>
-    <p>
-      <%= link_to "Show this player", player %>
-    </p>
   <% end %>
 </div>
 
diff --git a/app/views/players/show.html.erb b/app/views/players/show.html.erb
index 19ade1d..42dce9c 100644
--- a/app/views/players/show.html.erb
+++ b/app/views/players/show.html.erb
@@ -1,9 +1,8 @@
 <p style="color: green"><%= notice %></p>
 
-<%= render @player %>
+<%= render "form", player: @player %>
 
 <div>
-  <%= link_to "Edit this player", edit_player_path(@player) %> |
   <%= link_to "Back to players", players_path %>
 
   <%= button_to "Destroy this player", @player, method: :delete %>
diff --git a/test/controllers/machines_controller_test.rb b/test/controllers/machines_controller_test.rb
index 61ec204..03b68e4 100644
--- a/test/controllers/machines_controller_test.rb
+++ b/test/controllers/machines_controller_test.rb
@@ -22,7 +22,7 @@ class MachinesControllerTest < ActionDispatch::IntegrationTest
       post machines_url, params: { machine: { edition: @machine.edition, name: @machine.name } }
     end
 
-    assert_redirected_to machine_url(Machine.last)
+    assert_redirected_to machines_url
   end
 
   test 'should show machine' do
@@ -30,14 +30,9 @@ class MachinesControllerTest < ActionDispatch::IntegrationTest
     assert_response :success
   end
 
-  test 'should get edit' do
-    get edit_machine_url(@machine)
-    assert_response :success
-  end
-
   test 'should update machine' do
     patch machine_url(@machine), params: { machine: { edition: @machine.edition, name: @machine.name } }
-    assert_redirected_to machine_url(@machine)
+    assert_redirected_to machines_url
   end
 
   test 'should destroy machine' do
diff --git a/test/controllers/players_controller_test.rb b/test/controllers/players_controller_test.rb
index 8e446f0..cd78d68 100644
--- a/test/controllers/players_controller_test.rb
+++ b/test/controllers/players_controller_test.rb
@@ -22,7 +22,7 @@ class PlayersControllerTest < ActionDispatch::IntegrationTest
       post players_url, params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } }
     end
 
-    assert_redirected_to player_url(Player.last)
+    assert_redirected_to players_url
   end
 
   test 'should show player' do
@@ -30,14 +30,9 @@ class PlayersControllerTest < ActionDispatch::IntegrationTest
     assert_response :success
   end
 
-  test 'should get edit' do
-    get edit_player_url(@player)
-    assert_response :success
-  end
-
   test 'should update player' do
     patch player_url(@player), params: { player: { name: @player.name, paid: @player.paid, strikes: @player.strikes } }
-    assert_redirected_to player_url(@player)
+    assert_redirected_to players_url
   end
 
   test 'should destroy player' do