create team picker
This commit is contained in:
parent
4cc1a2f9dc
commit
9a2d1bbf9c
|
@ -1,4 +1,8 @@
|
|||
class PagesController < ApplicationController
|
||||
def index
|
||||
@players = Player.all
|
||||
|
||||
group_size = Player.count
|
||||
@groups = Player.order(Arel.sql("RANDOM()")).each_slice
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<main>
|
||||
<nav>
|
||||
<%= link_to "Home", root_path %> ~
|
||||
<%= link_to "Manage Tables", machines_path %> ~
|
||||
<%= link_to "Add Players", players_path %> ~
|
||||
<%= link_to "Pick Random Table", controller: "machines", action: "random" %>
|
||||
<%= link_to "Tables", machines_path %> ~
|
||||
<%= link_to "Players", players_path %> ~
|
||||
<%= link_to "Pick Random", controller: "machines", action: "random" %>
|
||||
</nav>
|
||||
<hr>
|
||||
|
||||
|
|
|
@ -1,3 +1,31 @@
|
|||
<h1>nomi pinball</h1>
|
||||
<%= 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><%= player.name %></td>
|
||||
<td><%= player.paid %></td>
|
||||
<td><%= player.strikes %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<h2>teampicker</h2>
|
||||
|
||||
<% @players.order(Arel.sql("RANDOM()")).each_slice(@players.count % 4 == 0 ? 4 : 3).each.with_index(1) do |slice, i| %>
|
||||
<h3>Team <%= i %></h3>
|
||||
<ul>
|
||||
<% slice.each do |player| %>
|
||||
<li><%= player.name %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
|
|
Loading…
Reference in New Issue