puzzle-scoreboard/app/controllers/contests_controller.rb
sto 026bda2a99
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
Add users controller
2025-03-14 16:37:21 +01:00

39 lines
632 B
Ruby

class ContestsController < ApplicationController
before_action :set_contest, only: %i[ show destroy ]
def index
@contests = current_user.contests
@user = current_user
end
def show
end
def new
@contest = Contest.new
end
def create
@contest = Contest.new(contest_params)
@contest.user_id = current_user.id
if @contest.save
redirect_to @contest
else
render :new, status: :unprocessable_entity
end
end
def destroy
end
private
def set_contest
@contest = Contest.find(params[:id])
end
def contest_params
params.expect(contest: [ :name ])
end
end