From 28240bba27149f527f952be7fd92b3cfa88005b1 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 8 Jul 2022 22:36:47 +0200 Subject: [PATCH] Properly match notification type --- app/models/notification.rb | 3 +-- app/views/navigation/main/_notifications.haml | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/models/notification.rb b/app/models/notification.rb index db1b9b32..c0a99f68 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -31,7 +31,7 @@ class Notification < ApplicationRecord notif_type = target.notification_type return nil unless notif_type - notif = notif_type.find_by(recipient: recipient, target: target) + notif = Notification.find_by(recipient: recipient, target: target) notif.destroy unless notif.nil? end @@ -39,7 +39,6 @@ class Notification < ApplicationRecord def make_notification(recipient, target, notification_type) n = notification_type.new(target: target, - target_type: target.class.name, # To ensure we don't get a type of 'Appenddable' recipient: recipient, new: true) n.save! diff --git a/app/views/navigation/main/_notifications.haml b/app/views/navigation/main/_notifications.haml index 75d80928..2763591c 100644 --- a/app/views/navigation/main/_notifications.haml +++ b/app/views/navigation/main/_notifications.haml @@ -19,7 +19,7 @@ - else - notifications.each do |notification| .dropdown-item - = render "notifications/type/#{notification.target_type.downcase.split('::').last}", notification: notification + = render "notifications/type/#{notification.target.type.downcase.split('::').last}", notification: notification %a.dropdown-item.text-center{ href: notifications_path } %i.fa.fa-fw.fa-chevron-right