Add puzzles to contests
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run

This commit is contained in:
sto
2025-03-15 14:28:24 +01:00
parent eca2e46d23
commit 0cbd2e4fdc
10 changed files with 63 additions and 19 deletions

View File

@@ -8,6 +8,7 @@ class ContestsController < ApplicationController
def show
@title = @contest.name
@puzzles = @contest.puzzles
set_badges
end

View File

@@ -1,4 +1,5 @@
class PuzzlesController < ApplicationController
before_action :set_contest
before_action :set_puzzle, only: %i[ show destroy ]
def index
@@ -10,13 +11,16 @@ class PuzzlesController < ApplicationController
def new
@puzzle = Puzzle.new
@title = "New contest puzzle"
end
def create
@puzzle = Puzzle.new(puzzle_params)
@puzzle.contest_id = @contest.id
if @puzzle.save
redirect_to @puzzle
redirect_to contest_path(@contest)
else
@title = "New contest puzzle"
render :new, status: :unprocessable_entity
end
end
@@ -28,6 +32,10 @@ class PuzzlesController < ApplicationController
private
def set_contest
@contest = Contest.find(params[:contest_id])
end
def set_puzzle
@puzzle = Puzzle.find(params[:id])
end