From 73d22a126ab1f818b4df91312ae108002aab68f9 Mon Sep 17 00:00:00 2001
From: Jacob Cody Wimer
Date: Tue, 21 Jan 2014 21:43:48 -0500
Subject: [PATCH] The rest of 1-21 changes. Mostly visual flow between
tournament school and wrestlers
---
app/assets/stylesheets/application.css | 13 ----------
app/controllers/schools_controller.rb | 5 +++-
app/controllers/static_pages_controller.rb | 1 +
app/models/school.rb | 1 +
app/views/layouts/application.html.erb | 4 +--
app/views/schools/_form.html.erb | 13 ++++++++++
app/views/schools/show.html.erb | 5 ++++
app/views/static_pages/index.html.erb | 30 +++++++++++++++++-----
config/routes.rb | 2 ++
db/schema.rb | 12 ++++++++-
10 files changed, 62 insertions(+), 24 deletions(-)
delete mode 100644 app/assets/stylesheets/application.css
diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css
deleted file mode 100644
index 3192ec8..0000000
--- a/app/assets/stylesheets/application.css
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
- * This is a manifest file that'll be compiled into application.css, which will include all the files
- * listed below.
- *
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
- *
- * You're free to add application-wide styles to this file and they'll appear at the top of the
- * compiled file, but it's generally better to create a new file per style scope.
- *
- *= require_self
- *= require_tree .
- */
diff --git a/app/controllers/schools_controller.rb b/app/controllers/schools_controller.rb
index 9c3a763..db80dd3 100644
--- a/app/controllers/schools_controller.rb
+++ b/app/controllers/schools_controller.rb
@@ -16,6 +16,9 @@ class SchoolsController < ApplicationController
# GET /schools/new
def new
@school = School.new
+ if params[:tournament]
+ @tournament = params[:tournament]
+ end
end
# GET /schools/1/edit
@@ -70,6 +73,6 @@ class SchoolsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def school_params
- params.require(:school).permit(:name, :score)
+ params.require(:school).permit(:name, :score, :tournament_id)
end
end
diff --git a/app/controllers/static_pages_controller.rb b/app/controllers/static_pages_controller.rb
index c38239d..68317c3 100644
--- a/app/controllers/static_pages_controller.rb
+++ b/app/controllers/static_pages_controller.rb
@@ -1,6 +1,7 @@
class StaticPagesController < ApplicationController
def index
+ @tournaments = Tournament.all
end
def school
diff --git a/app/models/school.rb b/app/models/school.rb
index 47f747a..3e3a80a 100644
--- a/app/models/school.rb
+++ b/app/models/school.rb
@@ -1,3 +1,4 @@
class School < ActiveRecord::Base
+ belongs_to :tournament
has_many :wrestlers
end
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 9bf2cae..9dbc116 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -10,9 +10,7 @@
<%= render 'layouts/header' %>
- <% flash.each do |key, value| %>
-
<%= value %>
- <% end %>
+
<%= yield %>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
diff --git a/app/views/schools/_form.html.erb b/app/views/schools/_form.html.erb
index 7fa388f..e82de7a 100644
--- a/app/views/schools/_form.html.erb
+++ b/app/views/schools/_form.html.erb
@@ -19,6 +19,19 @@
<%= f.label :score %>
<%= f.number_field :score %>
+
+
+
+<% if @school %>
+ <%= f.hidden_field :tournament_id, :value => @tournament %>
+ <% else %>
+
+ <%= f.label 'Tournament' %>
+ <%= f.collection_select :tournament_id, Tournament.all, :id, :name %>
+
+ <% end %>
+
+
<%= f.submit %>
diff --git a/app/views/schools/show.html.erb b/app/views/schools/show.html.erb
index 6f396d8..fb7d727 100644
--- a/app/views/schools/show.html.erb
+++ b/app/views/schools/show.html.erb
@@ -10,6 +10,11 @@
<%= @school.score %>
+
+ Tournament:
+ <%= Tournament.find(@school.tournament_id).name %>
+
+
<%= link_to "Edit #{@school.name}", edit_school_path(@school) %> |
<%= link_to 'Back to Schools', schools_path %> |
<%= link_to 'Back to Admin', '/admin/index' %>
diff --git a/app/views/static_pages/index.html.erb b/app/views/static_pages/index.html.erb
index 8aca099..20aa85c 100644
--- a/app/views/static_pages/index.html.erb
+++ b/app/views/static_pages/index.html.erb
@@ -1,7 +1,25 @@
-CCHS Wrestling
-1st Annual Comet Classic
-Central Crossing High School
-4500 Big Run South Rd, Grove City, OH
+Pick A Tournament
+<%= link_to 'New Tournament', new_tournament_path, :class=>"btn" %>
+
+
+
+
+
+ | Name |
+ |
+
+
+
+
+ <% @tournaments.each do |tournament| %>
+
+ | <%= tournament.name %> |
+ <%= link_to 'Show', tournament, :class=>"btn" %><%= link_to 'Edit', edit_tournament_path(tournament), :class=>"btn" %><%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' }, :class=>"btn btn-danger" %> |
+
+ <% end %>
+
+
+
-
-
View Larger Map
\ No newline at end of file
+
+
diff --git a/config/routes.rb b/config/routes.rb
index 69300d3..30a2a82 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,4 +1,6 @@
Wrestling::Application.routes.draw do
+ resources :tournaments
+
resources :schools
resources :weights
diff --git a/db/schema.rb b/db/schema.rb
index 34de1f8..fd10b7b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,13 +11,23 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20131231135039) do
+ActiveRecord::Schema.define(version: 20140121020833) 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"
+ end
+
+ create_table "tournaments", force: true do |t|
+ t.string "name"
+ t.string "address"
+ t.string "director"
+ t.string "director_email"
+ t.datetime "created_at"
+ t.datetime "updated_at"
end
create_table "weights", force: true do |t|