FIX: no error when assigned post is deleted (#244)

When an assigned post is deleted, we should not error. For now, assignment object is left untouched to not lose information when post is `undeleted`.

We can change that behaviour later if we decide that assignments should be deleted as well.
This commit is contained in:
Krzysztof Kotlarek 2021-11-16 09:12:51 +11:00 committed by GitHub
parent 6354215341
commit 677d6a9aed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -425,7 +425,7 @@ after_initialize do
add_to_class(:topic, :indirectly_assigned_to) do
return @indirectly_assigned_to if defined?(@indirectly_assigned_to)
@indirectly_assigned_to = Assignment.where(topic_id: id, target_type: "Post").inject({}) do |acc, assignment|
acc[assignment.target.post_number] = assignment.assigned_to
acc[assignment.target.post_number] = assignment.assigned_to if assignment.target
acc
end
end