Improve contest view
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
class PuzzlesController < ApplicationController
|
||||
before_action :set_contest
|
||||
before_action :set_puzzle, only: %i[ show destroy ]
|
||||
before_action :set_puzzle, only: %i[ edit destroy show update]
|
||||
|
||||
def index
|
||||
@puzzles = Puzzle.all
|
||||
@@ -9,6 +9,10 @@ class PuzzlesController < ApplicationController
|
||||
def show
|
||||
end
|
||||
|
||||
def edit
|
||||
@title = "Edit contest puzzle"
|
||||
end
|
||||
|
||||
def new
|
||||
@puzzle = Puzzle.new
|
||||
@title = "New contest puzzle"
|
||||
@@ -25,6 +29,14 @@ class PuzzlesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @puzzle.update(puzzle_params)
|
||||
redirect_to @contest
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@puzzle.destroy
|
||||
redirect_to puzzles_path
|
||||
|
Reference in New Issue
Block a user