From 23bb698f7412cbbb851b9f752ea81c4e6adfbc6b Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Tue, 23 Oct 2018 14:59:11 +0200 Subject: [PATCH 1/2] Fix retrieval of user_exercise_feedback and exercise --- app/controllers/user_exercise_feedbacks_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb index 841357e1..fffb95fc 100644 --- a/app/controllers/user_exercise_feedbacks_controller.rb +++ b/app/controllers/user_exercise_feedbacks_controller.rb @@ -103,8 +103,8 @@ class UserExerciseFeedbacksController < ApplicationController end def set_user_exercise_feedback - @exercise = Exercise.find(params[:user_exercise_feedback][:exercise_id]) - @uef = UserExerciseFeedback.find_by(exercise_id: params[:user_exercise_feedback][:exercise_id], user: current_user) + @uef = UserExerciseFeedback.find(params[:id]) + @exercise = @uef.exercise end def set_user_exercise_feedback_by_id From 9507bdb329a336484955a82b935bb9cf2c42126a Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Thu, 15 Nov 2018 17:15:57 +0100 Subject: [PATCH 2/2] cleanup duplicate code --- app/controllers/user_exercise_feedbacks_controller.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/controllers/user_exercise_feedbacks_controller.rb b/app/controllers/user_exercise_feedbacks_controller.rb index fffb95fc..a3c71abc 100644 --- a/app/controllers/user_exercise_feedbacks_controller.rb +++ b/app/controllers/user_exercise_feedbacks_controller.rb @@ -1,8 +1,7 @@ class UserExerciseFeedbacksController < ApplicationController include CommonBehavior - before_action :set_user_exercise_feedback, only: [:edit, :update] - before_action :set_user_exercise_feedback_by_id, only: [:show, :destroy] + before_action :set_user_exercise_feedback, only: [:edit, :update, :show, :destroy] def comment_presets [[0,t('user_exercise_feedback.difficulty_easy')], @@ -107,10 +106,6 @@ class UserExerciseFeedbacksController < ApplicationController @exercise = @uef.exercise end - def set_user_exercise_feedback_by_id - @uef = UserExerciseFeedback.find(params[:id]) - end - def uef_params params[:user_exercise_feedback].permit(:feedback_text, :difficulty, :exercise_id, :user_estimated_worktime).merge(user_id: current_user.id, user_type: current_user.class.name) if params[:user_exercise_feedback].present? end