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.

68 lines
1.6 KiB

10 months ago
10 months ago
10 months ago
5 months ago
10 months ago
4 months ago
10 months ago
  1. # ScoresController define Score and Grade interactions
  2. class ScoresController < ApplicationController
  3. include Pagy::Backend
  4. before_action :set_score, only: %i[show edit update destroy]
  5. # GET /scores
  6. def index
  7. @pagy, @scores = pagy(Score.all)
  8. # logger.info("#{HotConstants.boolean}")
  9. logger.info('start', dimensions: AnsiDimensions.start)
  10. logger.info('end', dimensions: AnsiDimensions.end)
  11. logger.info('around', dimensions: AnsiDimensions.around)
  12. end
  13. # GET /scores/1
  14. def show; end
  15. # GET /scores/new
  16. def new
  17. @score = Score.new
  18. end
  19. # GET /scores/1/edit
  20. def edit; end
  21. # POST /scores
  22. def create
  23. @score = Score.new(score_params)
  24. if @score.save
  25. redirect_to @score, notice: 'Score was successfully created.'
  26. else
  27. render :new, status: :unprocessable_entity
  28. end
  29. end
  30. # PATCH/PUT /scores/1
  31. def update
  32. if @score.update(score_params)
  33. redirect_to @score, notice: 'Score was successfully updated.', status: :see_other
  34. else
  35. render :edit, status: :unprocessable_entity
  36. end
  37. end
  38. # DELETE /scores/1
  39. def destroy
  40. # @score.destroy!
  41. # redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other
  42. flash.now[:alert] = "this is 'destroyed!'"
  43. render turbo_stream: turbo_stream.replace('notification', partial: 'layouts/notification')
  44. end
  45. private
  46. # Use callbacks to share common setup or constraints between actions.
  47. def set_score
  48. @score = Score.find(params[:id])
  49. @score.grade
  50. end
  51. # Only allow a list of trusted parameters through.
  52. def score_params
  53. params.require(:score).permit(:name, :grade)
  54. end
  55. end