app/controllers/clubs_controller.rb
# Controller for +Club+ model.
class ClubsController < ApplicationController
load_and_authorize_resource
# GET /clubs
# GET /clubs.json
def index
@clubs = Club.order(name: :asc)
end
# GET /clubs/1
# GET /clubs/1.json
def show
end
# GET /clubs/new
def new
@club = Club.new
end
# GET /clubs/1/edit
def edit
end
# POST /clubs
# POST /clubs.json
def create
@club = Club.new(club_params)
respond_to do |format|
if @club.save
format.html { redirect_to @club, notice: 'Club was successfully created.' }
format.json { render action: 'show', status: :created, location: @club }
else
format.html { render action: 'new' }
format.json { render json: @club.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /clubs/1
# PATCH/PUT /clubs/1.json
def update
respond_to do |format|
if @club.update(club_params)
format.html { redirect_to @club, notice: 'Club was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @club.errors, status: :unprocessable_entity }
end
end
end
# DELETE /clubs/1
# DELETE /clubs/1.json
def destroy
@club.destroy
respond_to do |format|
format.html { redirect_to clubs_url }
format.json { head :no_content }
end
end
private
def club_params
params.require(:club).permit(:name, :conference, :primary_color, :secondary_color, :accent_color, :abbrv, :crest, :api_id)
end
end