Implement update
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
class ExerciseCollectionsController < ApplicationController
|
||||
include CommonBehavior
|
||||
|
||||
before_action :set_exercise_collection, only: [:show]
|
||||
before_action :set_exercise_collection, only: [:show, :edit, :update]
|
||||
|
||||
def index
|
||||
@exercise_collections = ExerciseCollection.all.paginate(:page => params[:page])
|
||||
@ -10,6 +11,12 @@ class ExerciseCollectionsController < ApplicationController
|
||||
def show
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
update_and_respond(object: @exercise_collection, params: exercise_collection_params)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@ -21,4 +28,8 @@ class ExerciseCollectionsController < ApplicationController
|
||||
def authorize!
|
||||
authorize(@exercise_collection || @exercise_collections)
|
||||
end
|
||||
|
||||
def exercise_collection_params
|
||||
params[:exercise_collection].permit(:name, :exercise_ids)
|
||||
end
|
||||
end
|
||||
|
11
app/views/exercise_collections/_form.html.slim
Normal file
11
app/views/exercise_collections/_form.html.slim
Normal file
@ -0,0 +1,11 @@
|
||||
- exercises = Exercise.all
|
||||
|
||||
= form_for(@exercise_collection, data: {exercises: exercises}, multipart: true) do |f|
|
||||
= render('shared/form_errors', object: @exercise_collection)
|
||||
.form-group
|
||||
= f.label(:name)
|
||||
= f.text_field(:name, class: 'form-control', required: true)
|
||||
.form-group
|
||||
= f.label(:exercises)
|
||||
= f.collection_select(:exercise_ids, exercises, :id, :title, {}, {class: 'form-control', multiple: true})
|
||||
.actions = render('shared/submit_button', f: f, object: @exercise_collection)
|
1
app/views/exercise_collections/edit.html.slim
Normal file
1
app/views/exercise_collections/edit.html.slim
Normal file
@ -0,0 +1 @@
|
||||
= render('form')
|
Reference in New Issue
Block a user