tidy up lists
This commit is contained in:
parent
68f5f71701
commit
d1a328f413
|
@ -20,7 +20,7 @@ class MachinesController < ApplicationController
|
||||||
@machine = Machine.new(machine_params)
|
@machine = Machine.new(machine_params)
|
||||||
|
|
||||||
if @machine.save
|
if @machine.save
|
||||||
redirect_to @machine
|
redirect_to machines_path
|
||||||
else
|
else
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
|
@ -34,7 +34,7 @@ class MachinesController < ApplicationController
|
||||||
@machine = Machine.find(params[:id])
|
@machine = Machine.find(params[:id])
|
||||||
|
|
||||||
if @machine.update(machine_params)
|
if @machine.update(machine_params)
|
||||||
redirect_to @machine
|
redirect_to machines_path
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,7 +11,7 @@ class PagesController < ApplicationController
|
||||||
|
|
||||||
private
|
private
|
||||||
def maketeams
|
def maketeams
|
||||||
r = Player.where("strikes < 4").order(Arel.sql("RANDOM()")).to_a
|
r = Player.where("strikes < 3").order(Arel.sql("RANDOM()")).to_a
|
||||||
|
|
||||||
groups = case r.size
|
groups = case r.size
|
||||||
when 5
|
when 5
|
||||||
|
|
|
@ -15,7 +15,7 @@ class PlayersController < ApplicationController
|
||||||
@player = Player.new(player_params)
|
@player = Player.new(player_params)
|
||||||
|
|
||||||
if @player.save
|
if @player.save
|
||||||
redirect_to @player
|
redirect_to players_path
|
||||||
else
|
else
|
||||||
render :new
|
render :new
|
||||||
end
|
end
|
||||||
|
@ -29,7 +29,7 @@ class PlayersController < ApplicationController
|
||||||
@player = Player.find(params[:id])
|
@player = Player.find(params[:id])
|
||||||
|
|
||||||
if @player.update(player_params)
|
if @player.update(player_params)
|
||||||
redirect_to @player
|
redirect_to players_path
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<%= form_with model: @machine do |form| %>
|
<%= form_with model: @machine, data: { "turbo" => "false" } do |form| %>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :name %><br>
|
<%= form.label :name %><br>
|
||||||
|
|
|
@ -2,3 +2,7 @@
|
||||||
|
|
||||||
<%= render "form", machine: @machine %>
|
<%= render "form", machine: @machine %>
|
||||||
|
|
||||||
|
<p><%= link_to "Delete #{@machine.name}", machine_path(@machine),
|
||||||
|
method: :delete,
|
||||||
|
data: { confirm: "Are you sure?" } %></p>
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,22 @@
|
||||||
<h1>Pinball Machines</h1>
|
<h1>Pinball Machines</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Edition</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @machines.each do |machine| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= link_to machine.name, edit_machine_path(machine) %></td>
|
||||||
|
<td><%= machine.edition %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<hr>
|
||||||
<p><%= @machines.size %> available machines</p>
|
<p><%= @machines.size %> available machines</p>
|
||||||
<ul>
|
<%= link_to "+ Add Machine", new_machine_path %>
|
||||||
<% @machines.each do |machine| %>
|
|
||||||
<li>
|
|
||||||
<%= link_to machine.name, machine %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<%= link_to "Add Machine", new_machine_path %>
|
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,3 @@
|
||||||
<h1>nomi pinball</h1>
|
<h1>nomi pinball</h1>
|
||||||
<%= image_tag "coinslotlogo.png" %>
|
<%= image_tag "coinslotlogo.png" %>
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Paid</th>
|
|
||||||
<th>Strikes</th>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% @players.order("strikes").each do |player| %>
|
|
||||||
<tr>
|
|
||||||
<td><%= link_to player.name, edit_player_path(player) %></td>
|
|
||||||
<td><%= player.paid %></td>
|
|
||||||
<td><%= player.strikes %></td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<%= form_with model: @player do |form| %>
|
<%= form_with model: @player, data: { "turbo" => "false" } do |form| %>
|
||||||
<br>
|
<br>
|
||||||
<div>
|
<div>
|
||||||
<%= form.label :name %><br>
|
<%= form.label :name %><br>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
<%= render "form", machine: @player %>
|
<%= render "form", machine: @player %>
|
||||||
|
|
||||||
<%= link_to "Delete", player_path(@player),
|
<%= link_to "Delete #{@player.name}", player_path(@player),
|
||||||
method: :delete,
|
method: :delete,
|
||||||
data: { confirm: "Are you sure?" } %>
|
data: { confirm: "Are you sure?" } %>
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,25 @@
|
||||||
<h1>Pinball Players</h1>
|
<h1>Pinball Players</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Paid</th>
|
||||||
|
<th>Strikes</th>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @players.order("strikes").each do |player| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= link_to player.name, edit_player_path(player) %></td>
|
||||||
|
<td><% if player.paid %>✓<% end %></td>
|
||||||
|
<td><%= player.strikes %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<hr>
|
||||||
<p><%= @players.size %> available players</p>
|
<p><%= @players.size %> available players</p>
|
||||||
<ul>
|
|
||||||
<% @players.each do |player| %>
|
|
||||||
<li>
|
|
||||||
<%= link_to player.name, player %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<%= link_to "Add player", new_player_path %>
|
<%= link_to "+ Add player", new_player_path %>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue