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

@ -6,7 +6,7 @@ tr.table-row-clickable data-id=request_for_comment.id data-href=request_for_comm
span.fa-solid.fa-check.fa-2x style="color: var(--bs-secondary-text-emphasis);" aria-hidden="true"
- else
= ''
td.text-center = request_for_comment.comments_count
td.text-center = request_for_comment.comments.size
- if request_for_comment.has_attribute?(:question) && request_for_comment.question.present?
td.text-primary = truncate(request_for_comment.question, length: 200)
- else

View File

@ -45,7 +45,7 @@ h1 = RequestForComment.model_name.human(count: 2)
td = truncate(request_for_comment.question, length: 200)
- else
td = '-'
td = request_for_comment.comments_count
td = request_for_comment.comments.size
td = link_to_if(request_for_comment.user && policy(request_for_comment.user).show?, request_for_comment.user.displayname, request_for_comment.user)
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.created_at))
td = t('shared.time.before', time: distance_of_time_in_words_to_now(request_for_comment.last_comment.nil? ? request_for_comment.updated_at : request_for_comment.last_comment))