mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-04 13:43:48 +00:00
A ton of stuff was done to finalize the app for use
This commit is contained in:
@@ -19,11 +19,26 @@ class MatchesController < ApplicationController
|
||||
|
||||
# GET /matches/1/edit
|
||||
def edit
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
if params[:match]
|
||||
@match = Match.find (params[:match])
|
||||
end
|
||||
if @match
|
||||
@w1 = Wrestler.find(@match.r_id)
|
||||
@w2 = Wrestler.find(@match.g_id)
|
||||
end
|
||||
end
|
||||
|
||||
# POST /matches
|
||||
# POST /matches.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@match = Match.new(match_params)
|
||||
|
||||
respond_to do |format|
|
||||
@@ -40,9 +55,13 @@ class MatchesController < ApplicationController
|
||||
# PATCH/PUT /matches/1
|
||||
# PATCH/PUT /matches/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @match.update(match_params)
|
||||
format.html { redirect_to @match, notice: 'Match was successfully updated.' }
|
||||
format.html { redirect_to root_path, notice: 'Match was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: 'edit' }
|
||||
@@ -54,6 +73,10 @@ class MatchesController < ApplicationController
|
||||
# DELETE /matches/1
|
||||
# DELETE /matches/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@match.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to matches_url }
|
||||
@@ -69,6 +92,6 @@ class MatchesController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def match_params
|
||||
params.require(:match).permit(:r_id, :g_id, :g_stat, :r_stat, :winner_id, :win_type, :score)
|
||||
params.require(:match).permit(:r_id, :g_id, :g_stat, :r_stat, :winner_id, :win_type, :score, :finished)
|
||||
end
|
||||
end
|
||||
|
||||
93
app/controllers/mats_controller.rb
Normal file
93
app/controllers/mats_controller.rb
Normal file
@@ -0,0 +1,93 @@
|
||||
class MatsController < ApplicationController
|
||||
before_action :set_mat, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /mats
|
||||
# GET /mats.json
|
||||
def index
|
||||
@mats = Mat.all
|
||||
end
|
||||
|
||||
# GET /mats/1
|
||||
# GET /mats/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /mats/new
|
||||
def new
|
||||
@mat = Mat.new
|
||||
if params[:tournament]
|
||||
@tournament_field = params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
end
|
||||
end
|
||||
|
||||
# GET /mats/1/edit
|
||||
def edit
|
||||
@tournament_field = @mat.tournament_id
|
||||
end
|
||||
|
||||
# POST /mats
|
||||
# POST /mats.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@mat = Mat.new(mat_params)
|
||||
@tournament = Tournament.find(mat_params[:tournament_id])
|
||||
respond_to do |format|
|
||||
if @mat.save
|
||||
format.html { redirect_to @tournament, notice: 'Mat was successfully created.' }
|
||||
format.json { render action: 'show', status: :created, location: @mat }
|
||||
else
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @mat.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /mats/1
|
||||
# PATCH/PUT /mats/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@mat.tournament_id)
|
||||
respond_to do |format|
|
||||
if @mat.update(mat_params)
|
||||
format.html { redirect_to @tournament, notice: 'Mat was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @mat.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /mats/1
|
||||
# DELETE /mats/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@mat.tournament_id)
|
||||
@mat.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to @tournament }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_mat
|
||||
@mat = Mat.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def mat_params
|
||||
params.require(:mat).permit(:name, :tournament_id)
|
||||
end
|
||||
end
|
||||
@@ -31,6 +31,10 @@ class SchoolsController < ApplicationController
|
||||
# POST /schools
|
||||
# POST /schools.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@school = School.new(school_params)
|
||||
@tournament = Tournament.find(school_params[:tournament_id])
|
||||
respond_to do |format|
|
||||
@@ -47,6 +51,10 @@ class SchoolsController < ApplicationController
|
||||
# PATCH/PUT /schools/1
|
||||
# PATCH/PUT /schools/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@school.tournament_id)
|
||||
respond_to do |format|
|
||||
if @school.update(school_params)
|
||||
@@ -62,6 +70,10 @@ class SchoolsController < ApplicationController
|
||||
# DELETE /schools/1
|
||||
# DELETE /schools/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@school.tournament_id)
|
||||
@school.destroy
|
||||
respond_to do |format|
|
||||
|
||||
@@ -3,7 +3,25 @@ class StaticPagesController < ApplicationController
|
||||
def index
|
||||
@tournaments = Tournament.all
|
||||
end
|
||||
def up_matches
|
||||
if params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
end
|
||||
if @tournament
|
||||
@matches = Weight.where(tournament_id: @tournament.id)
|
||||
end
|
||||
@matches = Match.where(finished: nil)
|
||||
end
|
||||
def results
|
||||
if params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
end
|
||||
if @tournament
|
||||
@matches = Weight.where(tournament_id: @tournament.id)
|
||||
end
|
||||
@matches = Match.where(finished: 1)
|
||||
|
||||
end
|
||||
def brackets
|
||||
if params[:weight]
|
||||
@weight = Weight.find(params[:weight])
|
||||
@@ -33,5 +51,226 @@ class StaticPagesController < ApplicationController
|
||||
@weights = Weight.where(tournament_id: @tournament.id)
|
||||
end
|
||||
end
|
||||
|
||||
def generate_matches
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
if params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
end
|
||||
if @tournament
|
||||
@matches_all = Match.where(tournament_id: @tournament.id)
|
||||
@matches_all.each do |match|
|
||||
match.destroy
|
||||
end
|
||||
@weights = Weight.where(tournament_id: @tournament.id)
|
||||
#ROUND 1
|
||||
@weights.order("id asc").each do |weight|
|
||||
@seed1 = Wrestler.where(weight_id: weight.id, original_seed: 1).first
|
||||
@seed10 = Wrestler.where(weight_id: weight.id, original_seed: 10).first
|
||||
@seed7 = Wrestler.where(weight_id: weight.id, original_seed: 7).first
|
||||
@seed5 = Wrestler.where(weight_id: weight.id, original_seed: 5).first
|
||||
@seed4 = Wrestler.where(weight_id: weight.id, original_seed: 4).first
|
||||
@seed2 = Wrestler.where(weight_id: weight.id, original_seed: 2).first
|
||||
@seed9 = Wrestler.where(weight_id: weight.id, original_seed: 9).first
|
||||
@seed6 = Wrestler.where(weight_id: weight.id, original_seed: 6).first
|
||||
@seed8 = Wrestler.where(weight_id: weight.id, original_seed: 8).first
|
||||
@seed3 = Wrestler.where(weight_id: weight.id, original_seed: 3).first
|
||||
@bracket_size = Wrestler.where(weight_id: weight.id).count
|
||||
def createMatch(r_id,g_id,tournament)
|
||||
@match = Match.new
|
||||
@match.r_id = r_id
|
||||
@match.g_id = g_id
|
||||
@match.tournament_id = tournament
|
||||
@match.round = 1
|
||||
@match.save
|
||||
end
|
||||
if @bracket_size == 10
|
||||
createMatch(@seed1.id,@seed10.id,@tournament.id)
|
||||
createMatch(@seed5.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed9.id,@tournament.id)
|
||||
createMatch(@seed6.id,@seed8.id,@tournament.id)
|
||||
elsif @bracket_size == 9
|
||||
createMatch(@seed1.id,@seed9.id,@tournament.id)
|
||||
createMatch(@seed5.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed6.id,@seed8.id,@tournament.id)
|
||||
elsif @bracket_size == 8
|
||||
createMatch(@seed5.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed6.id,@seed8.id,@tournament.id)
|
||||
elsif @bracket_size == 7
|
||||
createMatch(@seed5.id,@seed7.id,@tournament.id)
|
||||
end
|
||||
|
||||
end
|
||||
#ROUND 2
|
||||
@weights.order("id asc").each do |weight|
|
||||
@seed1 = Wrestler.where(weight_id: weight.id, original_seed: 1).first
|
||||
@seed10 = Wrestler.where(weight_id: weight.id, original_seed: 10).first
|
||||
@seed7 = Wrestler.where(weight_id: weight.id, original_seed: 7).first
|
||||
@seed5 = Wrestler.where(weight_id: weight.id, original_seed: 5).first
|
||||
@seed4 = Wrestler.where(weight_id: weight.id, original_seed: 4).first
|
||||
@seed2 = Wrestler.where(weight_id: weight.id, original_seed: 2).first
|
||||
@seed9 = Wrestler.where(weight_id: weight.id, original_seed: 9).first
|
||||
@seed6 = Wrestler.where(weight_id: weight.id, original_seed: 6).first
|
||||
@seed8 = Wrestler.where(weight_id: weight.id, original_seed: 8).first
|
||||
@seed3 = Wrestler.where(weight_id: weight.id, original_seed: 3).first
|
||||
@bracket_size = Wrestler.where(weight_id: weight.id).count
|
||||
def createMatch(r_id,g_id,tournament)
|
||||
@match = Match.new
|
||||
@match.r_id = r_id
|
||||
@match.g_id = g_id
|
||||
@match.tournament_id = tournament
|
||||
@match.round = 2
|
||||
@match.save
|
||||
end
|
||||
if @bracket_size == 10
|
||||
createMatch(@seed1.id,@seed5.id,@tournament.id)
|
||||
createMatch(@seed10.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed6.id,@tournament.id)
|
||||
createMatch(@seed9.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 9
|
||||
createMatch(@seed1.id,@seed5.id,@tournament.id)
|
||||
createMatch(@seed9.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed6.id,@tournament.id)
|
||||
elsif @bracket_size == 8
|
||||
createMatch(@seed1.id,@seed5.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed6.id,@tournament.id)
|
||||
elsif @bracket_size == 7
|
||||
createMatch(@seed1.id,@seed5.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed6.id,@tournament.id)
|
||||
end
|
||||
|
||||
end
|
||||
#ROUND 3
|
||||
@weights.order("id asc").each do |weight|
|
||||
@seed1 = Wrestler.where(weight_id: weight.id, original_seed: 1).first
|
||||
@seed10 = Wrestler.where(weight_id: weight.id, original_seed: 10).first
|
||||
@seed7 = Wrestler.where(weight_id: weight.id, original_seed: 7).first
|
||||
@seed5 = Wrestler.where(weight_id: weight.id, original_seed: 5).first
|
||||
@seed4 = Wrestler.where(weight_id: weight.id, original_seed: 4).first
|
||||
@seed2 = Wrestler.where(weight_id: weight.id, original_seed: 2).first
|
||||
@seed9 = Wrestler.where(weight_id: weight.id, original_seed: 9).first
|
||||
@seed6 = Wrestler.where(weight_id: weight.id, original_seed: 6).first
|
||||
@seed8 = Wrestler.where(weight_id: weight.id, original_seed: 8).first
|
||||
@seed3 = Wrestler.where(weight_id: weight.id, original_seed: 3).first
|
||||
@bracket_size = Wrestler.where(weight_id: weight.id).count
|
||||
def createMatch(r_id,g_id,tournament)
|
||||
@match = Match.new
|
||||
@match.r_id = r_id
|
||||
@match.g_id = g_id
|
||||
@match.tournament_id = tournament
|
||||
@match.round = 3
|
||||
@match.save
|
||||
end
|
||||
if @bracket_size == 10
|
||||
createMatch(@seed1.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed10.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed3.id,@tournament.id)
|
||||
createMatch(@seed8.id,@seed9.id,@tournament.id)
|
||||
elsif @bracket_size == 9
|
||||
createMatch(@seed1.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed9.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 8
|
||||
createMatch(@seed1.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 7
|
||||
createMatch(@seed1.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed3.id,@tournament.id)
|
||||
end
|
||||
|
||||
end
|
||||
#ROUND 4
|
||||
@weights.order("id asc").each do |weight|
|
||||
@seed1 = Wrestler.where(weight_id: weight.id, original_seed: 1).first
|
||||
@seed10 = Wrestler.where(weight_id: weight.id, original_seed: 10).first
|
||||
@seed7 = Wrestler.where(weight_id: weight.id, original_seed: 7).first
|
||||
@seed5 = Wrestler.where(weight_id: weight.id, original_seed: 5).first
|
||||
@seed4 = Wrestler.where(weight_id: weight.id, original_seed: 4).first
|
||||
@seed2 = Wrestler.where(weight_id: weight.id, original_seed: 2).first
|
||||
@seed9 = Wrestler.where(weight_id: weight.id, original_seed: 9).first
|
||||
@seed6 = Wrestler.where(weight_id: weight.id, original_seed: 6).first
|
||||
@seed8 = Wrestler.where(weight_id: weight.id, original_seed: 8).first
|
||||
@seed3 = Wrestler.where(weight_id: weight.id, original_seed: 3).first
|
||||
@bracket_size = Wrestler.where(weight_id: weight.id).count
|
||||
def createMatch(r_id,g_id,tournament)
|
||||
@match = Match.new
|
||||
@match.r_id = r_id
|
||||
@match.g_id = g_id
|
||||
@match.tournament_id = tournament
|
||||
@match.round = 4
|
||||
@match.save
|
||||
end
|
||||
if @bracket_size == 10
|
||||
createMatch(@seed1.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed5.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed8.id,@tournament.id)
|
||||
createMatch(@seed6.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 9
|
||||
createMatch(@seed1.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed5.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed8.id,@tournament.id)
|
||||
createMatch(@seed6.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 8
|
||||
createMatch(@seed1.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed5.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed2.id,@seed8.id,@tournament.id)
|
||||
createMatch(@seed6.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 7
|
||||
createMatch(@seed1.id,@seed7.id,@tournament.id)
|
||||
createMatch(@seed5.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed6.id,@seed3.id,@tournament.id)
|
||||
end
|
||||
|
||||
end
|
||||
#ROUND 5
|
||||
@weights.order("id asc").each do |weight|
|
||||
@seed1 = Wrestler.where(weight_id: weight.id, original_seed: 1).first
|
||||
@seed10 = Wrestler.where(weight_id: weight.id, original_seed: 10).first
|
||||
@seed7 = Wrestler.where(weight_id: weight.id, original_seed: 7).first
|
||||
@seed5 = Wrestler.where(weight_id: weight.id, original_seed: 5).first
|
||||
@seed4 = Wrestler.where(weight_id: weight.id, original_seed: 4).first
|
||||
@seed2 = Wrestler.where(weight_id: weight.id, original_seed: 2).first
|
||||
@seed9 = Wrestler.where(weight_id: weight.id, original_seed: 9).first
|
||||
@seed6 = Wrestler.where(weight_id: weight.id, original_seed: 6).first
|
||||
@seed8 = Wrestler.where(weight_id: weight.id, original_seed: 8).first
|
||||
@seed3 = Wrestler.where(weight_id: weight.id, original_seed: 3).first
|
||||
@bracket_size = Wrestler.where(weight_id: weight.id).count
|
||||
def createMatch(r_id,g_id,tournament)
|
||||
@match = Match.new
|
||||
@match.r_id = r_id
|
||||
@match.g_id = g_id
|
||||
@match.tournament_id = tournament
|
||||
@match.round = 5
|
||||
@match.save
|
||||
end
|
||||
if @bracket_size == 10
|
||||
createMatch(@seed10.id,@seed5.id,@tournament.id)
|
||||
createMatch(@seed7.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed9.id,@seed6.id,@tournament.id)
|
||||
createMatch(@seed8.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 9
|
||||
createMatch(@seed7.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed9.id,@seed5.id,@tournament.id)
|
||||
createMatch(@seed8.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 8
|
||||
createMatch(@seed7.id,@seed4.id,@tournament.id)
|
||||
createMatch(@seed8.id,@seed3.id,@tournament.id)
|
||||
elsif @bracket_size == 7
|
||||
createMatch(@seed7.id,@seed4.id,@tournament.id)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -12,6 +12,7 @@ class TournamentsController < ApplicationController
|
||||
def show
|
||||
@schools = @tournament.schools
|
||||
@weights = @tournament.weights
|
||||
@mats = @tournament.mats
|
||||
end
|
||||
|
||||
# GET /tournaments/new
|
||||
@@ -26,6 +27,10 @@ class TournamentsController < ApplicationController
|
||||
# POST /tournaments
|
||||
# POST /tournaments.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.new(tournament_params)
|
||||
respond_to do |format|
|
||||
if @tournament.save
|
||||
@@ -41,6 +46,10 @@ class TournamentsController < ApplicationController
|
||||
# PATCH/PUT /tournaments/1
|
||||
# PATCH/PUT /tournaments/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
respond_to do |format|
|
||||
if @tournament.update(tournament_params)
|
||||
format.html { redirect_to @tournament, notice: 'Tournament was successfully updated.' }
|
||||
@@ -55,6 +64,10 @@ class TournamentsController < ApplicationController
|
||||
# DELETE /tournaments/1
|
||||
# DELETE /tournaments/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to tournaments_url }
|
||||
|
||||
@@ -21,16 +21,22 @@ class WeightsController < ApplicationController
|
||||
@tournament_field = params[:tournament]
|
||||
@tournament = Tournament.find(params[:tournament])
|
||||
end
|
||||
@mats = Mat.where(tournament_id: @tournament.id)
|
||||
end
|
||||
|
||||
# GET /weights/1/edit
|
||||
def edit
|
||||
@tournament_field = @weight.tournament_id
|
||||
@mats = Mat.where(tournament_id: @weight.tournament.id)
|
||||
end
|
||||
|
||||
# POST /weights
|
||||
# POST /weights.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@weight = Weight.new(weight_params)
|
||||
@tournament = Tournament.find(weight_params[:tournament_id])
|
||||
respond_to do |format|
|
||||
@@ -47,6 +53,10 @@ class WeightsController < ApplicationController
|
||||
# PATCH/PUT /weights/1
|
||||
# PATCH/PUT /weights/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@weight.tournament_id)
|
||||
respond_to do |format|
|
||||
if @weight.update(weight_params)
|
||||
@@ -62,6 +72,10 @@ class WeightsController < ApplicationController
|
||||
# DELETE /weights/1
|
||||
# DELETE /weights/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@tournament = Tournament.find(@weight.tournament_id)
|
||||
@weight.destroy
|
||||
respond_to do |format|
|
||||
@@ -78,6 +92,6 @@ class WeightsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def weight_params
|
||||
params.require(:weight).permit(:max, :tournament_id)
|
||||
params.require(:weight).permit(:max, :tournament_id, :mat_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -43,6 +43,10 @@ class WrestlersController < ApplicationController
|
||||
# POST /wrestlers
|
||||
# POST /wrestlers.json
|
||||
def create
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@wrestler = Wrestler.new(wrestler_params)
|
||||
@school = School.find(wrestler_params[:school_id])
|
||||
respond_to do |format|
|
||||
@@ -59,6 +63,10 @@ class WrestlersController < ApplicationController
|
||||
# PATCH/PUT /wrestlers/1
|
||||
# PATCH/PUT /wrestlers/1.json
|
||||
def update
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@school = School.find(@wrestler.school_id)
|
||||
respond_to do |format|
|
||||
if @wrestler.update(wrestler_params)
|
||||
@@ -74,6 +82,10 @@ class WrestlersController < ApplicationController
|
||||
# DELETE /wrestlers/1
|
||||
# DELETE /wrestlers/1.json
|
||||
def destroy
|
||||
if user_signed_in?
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
@school = School.find(@wrestler.school_id)
|
||||
@wrestler.destroy
|
||||
respond_to do |format|
|
||||
|
||||
Reference in New Issue
Block a user