Skip to content

Instantly share code, notes, and snippets.

@adkron
Created February 24, 2015 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adkron/e8f964fa9b3e5fb7b94c to your computer and use it in GitHub Desktop.
Save adkron/e8f964fa9b3e5fb7b94c to your computer and use it in GitHub Desktop.
class TornamentsController < ApplicationController
before_action :authenticate_user!, only: [:new, :edit, :update, :destroy]
before_action :set_tornament, only: [:show, :edit, :update, :destroy]
respond_to :html
def index
@tornaments = Tornament.all
respond_with(@tornaments)
end
def show
respond_with(@tornament)
end
def new
@tornament = Tornament.new
respond_with(@tornament)
end
def edit
end
def create
@tornament = Tornament.new(tornament_params)
@tornament.save
respond_with(@tornament)
end
def update
@tornament.update(tornament_params)
respond_with(@tornament)
end
def destroy
@tornament.destroy
respond_with(@tornament)
end
private
def set_tornament
@tornament = Tornament.find(params[:id])
end
def tornament_params
params.require(:tornament).permit(:name, :city, :state, :description, :start_date, :end_date, :target_species, :headquarters, :num_fish_days, :num_lay_days, :base_entry_fee)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment