fixed broken exercise cloning

This commit is contained in:
Hauke Klement
2015-02-21 10:05:00 +01:00
parent 4a6e6eb5e6
commit 1f5ed5b914

View File

@ -16,12 +16,13 @@ class ExercisesController < ApplicationController
private :authorize! private :authorize!
def clone def clone
exercise = @exercise.duplicate(public: false, user: current_user) exercise = @exercise.duplicate(public: false, token: nil, user: current_user)
exercise.send(:generate_token)
if exercise.save if exercise.save
redirect_to(exercise, notice: t('shared.object_cloned', model: Exercise.model_name.human)) redirect_to(exercise, notice: t('shared.object_cloned', model: Exercise.model_name.human))
else else
flash[:danger] = t('shared.message_failure') flash[:danger] = t('shared.message_failure')
redirect_to(exercises_path) redirect_to(@exercise)
end end
end end