BenMusch/nu-tab

View on GitHub
app/controllers/judges_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true
Add an empty line after magic comments.
class JudgesController < ApplicationController
Use `%i` or `%I` for an array of symbols.
before_action :set_judge, only: [:show, :edit, :update, :destroy]
 
# GET /judges
def index
@judges = Judge.all
end
 
# GET /judges/1
Put empty method definitions on a single line.
def show
end
 
# GET /judges/new
def new
@judge = Judge.new
end
 
# GET /judges/1/edit
Put empty method definitions on a single line.
def edit
end
 
# POST /judges
def create
@judge = Judge.new(judge_params)
 
if @judge.save
redirect_to @judge, notice: 'Judge was successfully created.'
else
render :new
end
end
 
# PATCH/PUT /judges/1
def update
if @judge.update(judge_params)
redirect_to @judge, notice: 'Judge was successfully updated.'
else
render :edit
end
end
 
# DELETE /judges/1
def destroy
@judge.destroy
redirect_to judges_url, notice: 'Judge was successfully destroyed.'
end
 
Keep a blank line before and after `private`.
private
# Use callbacks to share common setup or constraints between actions.
Inconsistent indentation detected.
def set_judge
@judge = Judge.find(params[:id])
end
 
# Only allow a trusted parameter "white list" through.
Inconsistent indentation detected.
def judge_params
params.require(:judge).permit(:name, :rank, school_ids: [])
end
end