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.
 
 
 
 
 

62 lines
1.5 KiB

# ScoresController define Score and Grade interactions
class ScoresController < ApplicationController
include Pagy::Backend
before_action :set_score, only: %i[show edit update destroy]
def index
logger.info('inside controller2')
logger.info("multiline1\nmultiline2\nmultiline3")
logger.info('this is an info')
logger.debug('this is a debug')
logger.warn('this is a warning')
logger.error('this is an error')
logger.fatal('this is a fatal')
@q = Score.all.ransack(q_params)
@pagy, @scores = pagy(@q.result)
end
def show; end
def new
@score = Score.new
end
def edit; end
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
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
def destroy
zazaz
@score.destroy!
redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other
# flash.now[:alert] = "this is 'destroyed!'"
# render turbo_stream: turbo_stream.replace('notification', partial: 'layouts/notification')
end
private
def set_score = @score = Score.find(params[:id])
def score_params = params.require(:score).permit(:name, :grade)
def q_params = params.fetch(:q, {}).permit!
end