Fix evaluation comment email on system emails

Currently with both seeds and dev_seeds, not only was this email not
displayed from the system emails section, but it also caused an error in
the application.

@email_to had an empty value and in the view we tried to access
@email_to.name which caused the error. We kept the same logic but
added the current_user to make sure it always has a valid value. We add
the current_user because the current_user is always present in this controller..
This commit is contained in:
taitus
2022-05-10 14:58:12 +02:00
parent ba5893e755
commit 12ea724474
2 changed files with 28 additions and 17 deletions

View File

@@ -104,7 +104,7 @@ class Admin::SystemEmailsController < Admin::BaseController
comment = Comment.where(commentable_type: "Budget::Investment").last
if comment
@email = EvaluationCommentEmail.new(comment)
@email_to = @email.to.first
@email_to = @email.to.first || current_user
else
redirect_to admin_system_emails_path,
alert: t("admin.system_emails.alert.no_evaluation_comments")