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.

53 lines
1.3 KiB

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