From 6ada3e06700c983716240b2febbcb1e1a5411cba Mon Sep 17 00:00:00 2001 From: maebeale Date: Mon, 8 Jun 2026 14:11:34 -0400 Subject: [PATCH] Show sender on notifications index Surfaces who sent each notification so staff can distinguish portal-generated emails from staff-sent ones at a glance, rather than opening each record. Eager-loads the sender to avoid N+1. Co-Authored-By: Claude Opus 4.8 --- app/controllers/notifications_controller.rb | 2 +- app/views/notifications/_index.html.erb | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 7b6f53699..79836dff5 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -6,7 +6,7 @@ def index if turbo_frame_request? per_page = params[:number_of_items_per_page].presence || 25 - base_scope = authorized_scope(Notification.includes(:noticeable)) + base_scope = authorized_scope(Notification.includes(:noticeable, sender: :person)) filtered = base_scope.search_by_params(params.to_unsafe_h) @notifications = filtered.order(created_at: :desc) .paginate(page: params[:page], per_page: per_page) diff --git a/app/views/notifications/_index.html.erb b/app/views/notifications/_index.html.erb index 803e004e8..01be14ce6 100644 --- a/app/views/notifications/_index.html.erb +++ b/app/views/notifications/_index.html.erb @@ -3,7 +3,7 @@ Sent - Recipient + People Subject Record Responded @@ -30,9 +30,10 @@ <%#= notification.kind.to_s.humanize %> - + - <%= notification.recipient_email %> +
To: <%= notification.recipient_email %>
+
From: <%= notification.sender&.full_name.presence || "AWBW portal" %>