1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Added basic scaffolds for schools wrestlers and weights

This commit is contained in:
Jacob Cody Wimer
2013-12-31 11:23:43 -05:00
parent 5b6a127549
commit 24d9deee8b
57 changed files with 943 additions and 1 deletions

View File

@@ -0,0 +1,74 @@
class SchoolsController < ApplicationController
before_action :set_school, only: [:show, :edit, :update, :destroy]
# GET /schools
# GET /schools.json
def index
@schools = School.all
end
# GET /schools/1
# GET /schools/1.json
def show
end
# GET /schools/new
def new
@school = School.new
end
# GET /schools/1/edit
def edit
end
# POST /schools
# POST /schools.json
def create
@school = School.new(school_params)
respond_to do |format|
if @school.save
format.html { redirect_to @school, notice: 'School was successfully created.' }
format.json { render action: 'show', status: :created, location: @school }
else
format.html { render action: 'new' }
format.json { render json: @school.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /schools/1
# PATCH/PUT /schools/1.json
def update
respond_to do |format|
if @school.update(school_params)
format.html { redirect_to @school, notice: 'School was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @school.errors, status: :unprocessable_entity }
end
end
end
# DELETE /schools/1
# DELETE /schools/1.json
def destroy
@school.destroy
respond_to do |format|
format.html { redirect_to schools_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_school
@school = School.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def school_params
params.require(:school).permit(:name, :score)
end
end

View File

@@ -2,5 +2,9 @@ class StaticPagesController < ApplicationController
def index
end
def school
@school = School.all
end
end

View File

@@ -0,0 +1,75 @@
class WeightsController < ApplicationController
before_action :set_weight, only: [:show, :edit, :update, :destroy]
# GET /weights
# GET /weights.json
def index
@weights = Weight.all
end
# GET /weights/1
# GET /weights/1.json
def show
@wrestler = Wrestler.all
end
# GET /weights/new
def new
@weight = Weight.new
end
# GET /weights/1/edit
def edit
end
# POST /weights
# POST /weights.json
def create
@weight = Weight.new(weight_params)
respond_to do |format|
if @weight.save
format.html { redirect_to @weight, notice: 'Weight was successfully created.' }
format.json { render action: 'show', status: :created, location: @weight }
else
format.html { render action: 'new' }
format.json { render json: @weight.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /weights/1
# PATCH/PUT /weights/1.json
def update
respond_to do |format|
if @weight.update(weight_params)
format.html { redirect_to @weight, notice: 'Weight was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @weight.errors, status: :unprocessable_entity }
end
end
end
# DELETE /weights/1
# DELETE /weights/1.json
def destroy
@weight.destroy
respond_to do |format|
format.html { redirect_to weights_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_weight
@weight = Weight.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def weight_params
params.require(:weight).permit(:max)
end
end

View File

@@ -0,0 +1,74 @@
class WrestlersController < ApplicationController
before_action :set_wrestler, only: [:show, :edit, :update, :destroy]
# GET /wrestlers
# GET /wrestlers.json
def index
@wrestlers = Wrestler.all
end
# GET /wrestlers/1
# GET /wrestlers/1.json
def show
end
# GET /wrestlers/new
def new
@wrestler = Wrestler.new
end
# GET /wrestlers/1/edit
def edit
end
# POST /wrestlers
# POST /wrestlers.json
def create
@wrestler = Wrestler.new(wrestler_params)
respond_to do |format|
if @wrestler.save
format.html { redirect_to @wrestler, notice: 'Wrestler was successfully created.' }
format.json { render action: 'show', status: :created, location: @wrestler }
else
format.html { render action: 'new' }
format.json { render json: @wrestler.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /wrestlers/1
# PATCH/PUT /wrestlers/1.json
def update
respond_to do |format|
if @wrestler.update(wrestler_params)
format.html { redirect_to @wrestler, notice: 'Wrestler was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @wrestler.errors, status: :unprocessable_entity }
end
end
end
# DELETE /wrestlers/1
# DELETE /wrestlers/1.json
def destroy
@wrestler.destroy
respond_to do |format|
format.html { redirect_to wrestlers_url }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_wrestler
@wrestler = Wrestler.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def wrestler_params
params.require(:wrestler).permit(:name, :school_id, :weight_id, :seed, :original_seed)
end
end