Listing Tournaments

<% if @tournaments.length > 0 %> <%# Each tournament has a div for its listing %> <% @tournaments.each do |t| %>
<%= image_tag 'http://www.gravatar.com/avatar/' + Digest::MD5.hexdigest(t.hosts.first.email) + '?s=100&d=mm' %>
<%# "header" %> <%= link_to(t) do %>

<%= t.name %>

<% end %>
Hosted by: <%= t.hosts.first.name %>

Players per team: <%= t.min_players_per_team %>

Players signed up: <%= t.players.count %>

<%= (t.randomized_teams)? "Teams are Random" : "Teams are Chosen" %>

Players signed up: <%= t.players.count %>

<% if signed_in? %> <% if !t.players.include?(current_user) %> <%= form_tag(tournament_path(t), method: "put") do %> <%= submit_tag("Join") %> <% end %> <% else %>

You've signed up for this tournament!

<% end %> <% end %>
<% end %> <% else %>

No tournaments going on right now... <% if current_user.can?(:create_tournament) %> Why not start your own? <% end %>

<% end %>
<% if current_user.can?(:create_tournament) %>
<%= link_to 'New Tournament', new_tournament_path, :class => "btn btn-warning btn-lg" %>
<% end %>