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.

59 lines
1.4 KiB

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