2013-08-04 20:58:01 -04:00
|
|
|
class WorkoutsController < ApplicationController
|
|
|
|
def index
|
|
|
|
@workouts = Workout.all
|
|
|
|
end
|
2013-08-04 21:51:46 -04:00
|
|
|
|
|
|
|
def show
|
|
|
|
@workout = Workout.find(params[:id])
|
|
|
|
end
|
2013-08-05 01:07:11 -04:00
|
|
|
|
|
|
|
def edit
|
|
|
|
@workout = Workout.find(params[:id])
|
|
|
|
end
|
2013-08-10 08:36:43 -04:00
|
|
|
|
|
|
|
def update
|
|
|
|
params.permit!
|
|
|
|
@workout = Workout.find(params[:id])
|
|
|
|
|
|
|
|
if @workout.update_attributes(params[:workout])
|
|
|
|
redirect_to @workout, notice: 'Workout updated'
|
|
|
|
else
|
|
|
|
render action: 'edit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@workout = Workout.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
params.permit!
|
|
|
|
@workout = Workout.new(params[:workout])
|
|
|
|
|
|
|
|
if @workout.save
|
|
|
|
redirect_to @workout, notice: 'Workout created'
|
|
|
|
else
|
|
|
|
render action: 'new'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@workout = Workout.find(params[:id])
|
|
|
|
@workout.destroy
|
|
|
|
|
|
|
|
redirect_to workouts_url, notice: 'Workout deleted'
|
|
|
|
end
|
2013-08-04 20:58:01 -04:00
|
|
|
end
|