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

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