Add more workouts functionality and tests
This commit is contained in:
parent
10d4075f48
commit
456a071bf3
8 changed files with 114 additions and 18 deletions
|
@ -10,4 +10,37 @@ class WorkoutsController < ApplicationController
|
|||
def edit
|
||||
@workout = Workout.find(params[:id])
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue