mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Created Pool 1 of 10 Man Bracket
This commit is contained in:
@@ -4,8 +4,24 @@ class StaticPagesController < ApplicationController
|
||||
@tournaments = Tournament.all
|
||||
end
|
||||
|
||||
def school
|
||||
@school = School.all
|
||||
def brackets
|
||||
if params[:weight]
|
||||
@weight = Weight.find(params[:weight])
|
||||
@wrestlers = Wrestler.where(weight_id: @weight.id)
|
||||
@seed1 = Wrestler.where(weight_id: @weight.id, original_seed: 1).first
|
||||
end
|
||||
#@seed1 = @wrestlers.where(original_seed: 1).name
|
||||
|
||||
|
||||
end
|
||||
|
||||
def weights
|
||||
if params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
end
|
||||
if @tournament
|
||||
@weights = Weight.where(tournament_id: @tournament.id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
class School < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
has_many :wrestlers, dependent: :destroy
|
||||
|
||||
#calculate score here
|
||||
#def score
|
||||
# @score = 0
|
||||
# self.wrestlers.each do |w|
|
||||
# @score = @score + w.season_win * 2
|
||||
# end
|
||||
# self.score = @score
|
||||
#end
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<ul class="nav pull-right">
|
||||
<li><%= link_to "Home", root_path %></li>
|
||||
<% if @tournament %>
|
||||
<li><%= link_to "Brackets" , '#' %></li>
|
||||
<li><%= link_to "Brackets" , "/static_pages/weights?tournament=#{@tournament.id}" %></li>
|
||||
<li><%= link_to "Bout Board" , '#' %></li>
|
||||
<% end %>
|
||||
<% if user_signed_in? %>
|
||||
|
||||
@@ -15,13 +15,7 @@
|
||||
<%= f.label :name %><br>
|
||||
<%= f.text_field :name %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :score %><br>
|
||||
<%= f.number_field :score %>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<% if @school %>
|
||||
<%= f.hidden_field :tournament_id, :value => @tournament_field %>
|
||||
<% else %>
|
||||
|
||||
55
app/views/static_pages/_man10.html.erb
Normal file
55
app/views/static_pages/_man10.html.erb
Normal file
@@ -0,0 +1,55 @@
|
||||
<h1><%= @weight.max %> lbs Bracket</h1>
|
||||
<h3>Pool 1</h3>
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>R1</th>
|
||||
<th>R2</th>
|
||||
<th>R3</th>
|
||||
<th>R4</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>1. <%= @seed1.name %> <%= @seed1.season_win %>-<%= @seed1.season_loss %></td>
|
||||
<td>V2</td>
|
||||
<td>V3</td>
|
||||
<td>V5</td>
|
||||
<td>V4</td>
|
||||
<td>BYE</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>2. <%= @seed10.name %> <%= @seed10.season_win %>-<%= @seed10.season_loss %></td>
|
||||
<td>V1</td>
|
||||
<td>V5</td>
|
||||
<td>V4</td>
|
||||
<td>BYE</td>
|
||||
<td>V3</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>3. <%= @seed5.name %> <%= @seed5.season_win %>-<%= @seed5.season_loss %></td>
|
||||
<td>V4</td>
|
||||
<td>V1</td>
|
||||
<td>BYE</td>
|
||||
<td>V5</td>
|
||||
<td>V2</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>4. <%= @seed7.name %> <%= @seed7.season_win %>-<%= @seed7.season_loss %></td>
|
||||
<td>V3</td>
|
||||
<td>BYE</td>
|
||||
<td>V2</td>
|
||||
<td>V1</td>
|
||||
<td>V5</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>5. <%= @seed4.name %> <%= @seed4.season_win %>-<%= @seed4.season_loss %></td>
|
||||
<td>BYE</td>
|
||||
<td>V2</td>
|
||||
<td>V1</td>
|
||||
<td>V3</td>
|
||||
<td>V4</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
3
app/views/static_pages/brackets.html.erb
Normal file
3
app/views/static_pages/brackets.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<% if @wrestlers.count = 10 %>
|
||||
<%= render 'man10' %>
|
||||
<% end %>
|
||||
3
app/views/static_pages/weights.html.erb
Normal file
3
app/views/static_pages/weights.html.erb
Normal file
@@ -0,0 +1,3 @@
|
||||
<% @weights.each do |weight| %>
|
||||
<%= link_to "#{weight.max}" , "/static_pages/brackets?weight=#{weight.id}" %>
|
||||
<% end %>
|
||||
@@ -17,7 +17,8 @@ Wrestling::Application.routes.draw do
|
||||
|
||||
# You can have the root of your site routed with "root"
|
||||
root 'static_pages#index'
|
||||
get 'static_pages/school'
|
||||
get 'static_pages/brackets'
|
||||
get 'static_pages/weights'
|
||||
get 'admin/index'
|
||||
|
||||
# Example of regular route:
|
||||
|
||||
5
db/migrate/20140124015315_drop_school_score.rb
Normal file
5
db/migrate/20140124015315_drop_school_score.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class DropSchoolScore < ActiveRecord::Migration
|
||||
def change
|
||||
remove_column :schools, :score
|
||||
end
|
||||
end
|
||||
5
db/migrate/20140124021031_add_school_score.rb
Normal file
5
db/migrate/20140124021031_add_school_score.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
class AddSchoolScore < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :schools, :score, :integer
|
||||
end
|
||||
end
|
||||
@@ -11,14 +11,14 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140123035131) do
|
||||
ActiveRecord::Schema.define(version: 20140124021031) do
|
||||
|
||||
create_table "schools", force: true do |t|
|
||||
t.string "name"
|
||||
t.integer "score"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.integer "tournament_id"
|
||||
t.integer "score"
|
||||
end
|
||||
|
||||
create_table "tournaments", force: true do |t|
|
||||
|
||||
Reference in New Issue
Block a user