1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-17 05:15:36 +00:00

Updated re-directs, added weights to tournament#show, and edited a few views

This commit is contained in:
Jacob Cody Wimer
2014-01-22 13:12:40 -05:00
parent 4a463132da
commit d4b97c83c3
13 changed files with 91 additions and 20 deletions

View File

@@ -5,6 +5,7 @@ class WrestlersController < ApplicationController
# GET /wrestlers.json
def index
@wrestlers = Wrestler.all
#@school = School.find(@wrestler.school_id)
end
# GET /wrestlers/1
@@ -19,20 +20,30 @@ class WrestlersController < ApplicationController
@school_field = params[:school]
@school = School.find(params[:school])
end
if @school
@tournament = Tournament.find(@school.tournament_id)
end
if @tournament
@weight = Weight.where(tournament_id: @tournament.id)
else
@weight = Weight.all
end
end
# GET /wrestlers/1/edit
def edit
@school_field = @wrestler.school_id
end
# POST /wrestlers
# POST /wrestlers.json
def create
@wrestler = Wrestler.new(wrestler_params)
@school = School.find(wrestler_params[:school_id])
respond_to do |format|
if @wrestler.save
format.html { redirect_to @wrestler, notice: 'Wrestler was successfully created.' }
format.html { redirect_to @school, notice: 'Wrestler was successfully created.' }
format.json { render action: 'show', status: :created, location: @wrestler }
else
format.html { render action: 'new' }
@@ -44,9 +55,10 @@ class WrestlersController < ApplicationController
# PATCH/PUT /wrestlers/1
# PATCH/PUT /wrestlers/1.json
def update
@school = School.find(@wrestler.school_id)
respond_to do |format|
if @wrestler.update(wrestler_params)
format.html { redirect_to @wrestler, notice: 'Wrestler was successfully updated.' }
format.html { redirect_to @school, notice: 'Wrestler was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
@@ -58,9 +70,10 @@ class WrestlersController < ApplicationController
# DELETE /wrestlers/1
# DELETE /wrestlers/1.json
def destroy
@school = School.find(@wrestler.school_id)
@wrestler.destroy
respond_to do |format|
format.html { redirect_to wrestlers_url }
format.html { redirect_to @school }
format.json { head :no_content }
end
end