added interventions being saved once they are fired

This commit is contained in:
Thomas Hille
2017-02-28 16:06:45 +01:00
parent bfc96328c4
commit 904868394a
3 changed files with 24 additions and 9 deletions

View File

@ -173,12 +173,17 @@ class ExercisesController < ApplicationController
end
def intervention
uei = UserExerciseIntervention.new(
user: current_user, exercise: @exercise, intervention: Intervention.first,
accumulated_worktime: @exercise.accumulated_working_time_for_only(current_user))
intervention = Intervention.find_by_name(params[:intervention_type])
unless intervention.nil?
uei = UserExerciseIntervention.new(
user: current_user, exercise: @exercise, intervention: intervention,
accumulated_worktime_s: @exercise.accumulated_working_time_for_only(current_user))
uei.save
render(json: {success: 'true'})
else
render(json: {success: 'false', error: "undefined intervention #{params[:intervention_type]}"})
end
puts "user: #{current_user}, intervention: #{Intervention.first} #{uei.save}"
render(json: {success: 'true'})
end
def index