Add auth in all controllers

This commit is contained in:
sto
2025-03-22 13:07:12 +01:00
parent 5472a400d1
commit 6b02eecb9b
11 changed files with 107 additions and 6 deletions

View File

@@ -4,15 +4,21 @@ class ContestantsController < ApplicationController
before_action :set_completions, only: %i[edit update ]
def edit
authorize @contest
@title = "Contestant"
end
def new
authorize @contest
@contestant = Contestant.new
@title = "New contestant"
end
def create
authorize @contest
@contestant = Contestant.new(contestant_params)
@contestant.contest_id = @contest.id
if @contestant.save
@@ -24,6 +30,8 @@ class ContestantsController < ApplicationController
end
def update
authorize @contest
if @contestant.update(contestant_params)
redirect_to @contest
else
@@ -33,6 +41,8 @@ class ContestantsController < ApplicationController
end
def destroy
authorize @contest
@contestant.destroy
redirect_to contest_path(@contest)
end