You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.7 KiB
74 lines
1.7 KiB
# ScoresController define Score and Grade interactions
|
|
class ScoresController < ApplicationController
|
|
before_action :set_score, only: %i[show edit update destroy]
|
|
|
|
# GET /scores
|
|
def index
|
|
@scores = Score.all
|
|
# logger.debug 'this is a debug message'
|
|
logger.info(' ' + '*' * 200)
|
|
logger.debug({ 'one': 1, 'two': 2 })
|
|
logger.info 'this is an information', { 'four': 4, 'five': 5 }
|
|
# logger.info 'this is an object', BigDecimal('0.0001')
|
|
# logger.warn 'this is a warning'
|
|
# logger.error 'this is an error', BigDecimal('0.0002')
|
|
# logger.fatal 'FATAL'
|
|
# logger.debug 'score are', @scores
|
|
end
|
|
|
|
# GET /scores/1
|
|
def show; end
|
|
|
|
# GET /scores/new
|
|
def new
|
|
@score = Score.new
|
|
end
|
|
|
|
# GET /scores/1/edit
|
|
def edit; end
|
|
|
|
# POST /scores
|
|
def create
|
|
@score = Score.new(score_params)
|
|
|
|
if @score.save
|
|
redirect_to @score, notice: 'Score was successfully created.'
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
# PATCH/PUT /scores/1
|
|
def update
|
|
if @score.update(score_params)
|
|
redirect_to @score, notice: 'Score was successfully updated.', status: :see_other
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
# DELETE /scores/1
|
|
def destroy
|
|
do_an_exception
|
|
|
|
@score.destroy!
|
|
redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other
|
|
end
|
|
|
|
private
|
|
|
|
def do_an_exception
|
|
raise 'Unable to destroy this score'
|
|
end
|
|
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
def set_score
|
|
@score = Score.find(params[:id])
|
|
@score.grade
|
|
end
|
|
|
|
# Only allow a list of trusted parameters through.
|
|
def score_params
|
|
params.require(:score).permit(:name, :grade)
|
|
end
|
|
end
|