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.

55 lines
1.3 KiB

10 months ago
10 months ago
2 months ago
10 months ago
4 months ago
10 months ago
4 weeks ago
4 months ago
4 weeks ago
10 months ago
2 months ago
2 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. def index
  6. logger.info('inside controller2')
  7. logger.info("multiline1\nmultiline2\nmultiline3")
  8. @q = Score.all.ransack(q_params)
  9. @pagy, @scores = pagy(@q.result)
  10. end
  11. def show; end
  12. def new
  13. @score = Score.new
  14. end
  15. def edit; end
  16. def create
  17. @score = Score.new(score_params)
  18. if @score.save
  19. redirect_to @score, notice: 'Score was successfully created.'
  20. else
  21. render :new, status: :unprocessable_entity
  22. end
  23. end
  24. def update
  25. if @score.update(score_params)
  26. redirect_to @score, notice: 'Score was successfully updated.', status: :see_other
  27. else
  28. render :edit, status: :unprocessable_entity
  29. end
  30. end
  31. def destroy
  32. zazaz
  33. @score.destroy!
  34. redirect_to scores_url, notice: 'Score was successfully destroyed.', status: :see_other
  35. # flash.now[:alert] = "this is 'destroyed!'"
  36. # render turbo_stream: turbo_stream.replace('notification', partial: 'layouts/notification')
  37. end
  38. private
  39. def set_score = @score = Score.find(params[:id])
  40. def score_params = params.require(:score).permit(:name, :grade)
  41. def q_params = params.fetch(:q, {}).permit!
  42. end