Properly match notification type

This commit is contained in:
Karina Kwiatek 2022-07-08 22:36:47 +02:00 committed by Karina Kwiatek
parent b3f15fe409
commit 28240bba27
2 changed files with 2 additions and 3 deletions

View File

@ -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!

View File

@ -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