app/controllers/schools_controller.rb
# frozen_string_literal: trueAdd an empty line after magic comments.class SchoolsController < ApplicationControllerUse `%i` or `%I` for an array of symbols. before_action :set_school, only: [:show, :edit, :update, :destroy] # GET /schools def index @schools = School.all end # GET /schools/1Put empty method definitions on a single line. def show end # GET /schools/new def new @school = School.new end # GET /schools/1/editPut empty method definitions on a single line. def edit end # POST /schools def create @school = School.new(school_params) if @school.save redirect_to @school, notice: 'School was successfully created.' else render :new end end # PATCH/PUT /schools/1 def update if @school.update(school_params) redirect_to @school, notice: 'School was successfully updated.' else render :edit end end # DELETE /schools/1 def destroy @school.destroy redirect_to schools_url, notice: 'School was successfully destroyed.' end private # Use callbacks to share common setup or constraints between actions. def set_school @school = School.find(params[:id]) end # Only allow a trusted parameter "white list" through. def school_params params.require(:school).permit(:name) endend