Add auth in all controllers
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user