Public scoreboard scaffold
This commit is contained in:
@@ -26,4 +26,8 @@ class ApplicationController < ActionController::Base
|
||||
flash[:error] = t "#{policy_name}.#{exception.query}", scope: "pundit", default: :default
|
||||
redirect_back_or_to(root_path)
|
||||
end
|
||||
|
||||
def not_found
|
||||
render file: "#{Rails.root}/public/404.html", layout: false, status: :not_found
|
||||
end
|
||||
end
|
||||
|
@@ -1,5 +1,6 @@
|
||||
class ContestsController < ApplicationController
|
||||
before_action :set_contest, only: %i[ destroy edit show update ]
|
||||
skip_before_action :require_authentication, only: %i[ scoreboard ]
|
||||
|
||||
def index
|
||||
authorize :contest
|
||||
@@ -56,6 +57,20 @@ class ContestsController < ApplicationController
|
||||
authorize @contest
|
||||
end
|
||||
|
||||
def scoreboard
|
||||
@contest = Contest.find_by(slug: params[:id])
|
||||
unless @contest
|
||||
skip_authorization
|
||||
not_found and return
|
||||
end
|
||||
authorize @contest
|
||||
|
||||
@title = @contest.name
|
||||
@contestants = @contest.contestants.order(:name)
|
||||
@puzzles = @contest.puzzles.order(:id)
|
||||
render :scoreboard
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_badges
|
||||
|
Reference in New Issue
Block a user