Add association for Comments and RequestForComments

For the submission and comments, I mainly decided to use a `has_one` association. Based on the database schema, multiple request for comments could be allowed (i.e., for each file or submission), but this won't happen practically (since we always create new submissions and files). Hence, the `has_one` association is representing our relationship better.
This commit is contained in:
Sebastian Serth
2023-09-22 12:55:20 +02:00
committed by Sebastian Serth
parent b2f409fe63
commit 0e387ffda2
10 changed files with 12 additions and 13 deletions

View File

@ -41,9 +41,9 @@ class UserExerciseFeedbacksController < ApplicationController
Sentry.set_extras(params: uef_params)
@exercise = Exercise.find(uef_params[:exercise_id])
rfc = RequestForComment.unsolved.where(exercise_id: @exercise.id, user: current_user).first
rfc = RequestForComment.unsolved.where(exercise: @exercise, user: current_user).first
submission = begin
current_contributor.submissions.where(exercise_id: @exercise.id).order('created_at DESC').first
current_contributor.submissions.where(exercise: @exercise).order(created_at: :desc).first
rescue StandardError
nil
end