Implement new action

This commit is contained in:
Maximilian Grundke
2017-10-04 12:40:37 +02:00
parent 8e4a694690
commit e74c25746c
2 changed files with 21 additions and 2 deletions

View File

@ -1,7 +1,7 @@
class ExerciseCollectionsController < ApplicationController
include CommonBehavior
before_action :set_exercise_collection, only: [:show, :edit, :update]
before_action :set_exercise_collection, only: [:show, :edit, :update, :destroy]
def index
@exercise_collections = ExerciseCollection.all.paginate(:page => params[:page])
@ -11,6 +11,22 @@ class ExerciseCollectionsController < ApplicationController
def show
end
def new
@exercise_collection = ExerciseCollection.new
authorize!
end
def create
@exercise_collection = ExerciseCollection.new(exercise_collection_params)
authorize!
create_and_respond(object: @exercise_collection)
end
def destroy
authorize!
destroy_and_respond(object: @exercise_collection)
end
def edit
end
@ -30,6 +46,6 @@ class ExerciseCollectionsController < ApplicationController
end
def exercise_collection_params
params[:exercise_collection].permit(:name, :exercise_ids)
params[:exercise_collection].permit(:name, :exercise_ids => [])
end
end