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

@ -33,6 +33,7 @@ class Exercise < ApplicationRecord
has_many :internal_users, source: :contributor, source_type: 'InternalUser', through: :submissions
has_many :programming_groups
has_many :pair_programming_waiting_users
has_many :request_for_comments
scope :with_submissions, -> { where('id IN (SELECT exercise_id FROM submissions)') }