Implement new action
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
class ExerciseCollectionsController < ApplicationController
|
class ExerciseCollectionsController < ApplicationController
|
||||||
include CommonBehavior
|
include CommonBehavior
|
||||||
|
|
||||||
before_action :set_exercise_collection, only: [:show, :edit, :update]
|
before_action :set_exercise_collection, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@exercise_collections = ExerciseCollection.all.paginate(:page => params[:page])
|
@exercise_collections = ExerciseCollection.all.paginate(:page => params[:page])
|
||||||
@ -11,6 +11,22 @@ class ExerciseCollectionsController < ApplicationController
|
|||||||
def show
|
def show
|
||||||
end
|
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
|
def edit
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -30,6 +46,6 @@ class ExerciseCollectionsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def exercise_collection_params
|
def exercise_collection_params
|
||||||
params[:exercise_collection].permit(:name, :exercise_ids)
|
params[:exercise_collection].permit(:name, :exercise_ids => [])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
3
app/views/exercise_collections/new.html.slim
Normal file
3
app/views/exercise_collections/new.html.slim
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
h1 = t('shared.new_model', model: ExerciseCollection.model_name.human)
|
||||||
|
|
||||||
|
= render('form')
|
Reference in New Issue
Block a user