From 9c4b2e452a905a85b9000751ec85ef15acbb1858 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 5 Mar 2023 14:15:52 +0100 Subject: [PATCH] Prevent error when no one is subscribed --- app/models/subscription.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/subscription.rb b/app/models/subscription.rb index 507cc55c..b7971a98 100644 --- a/app/models/subscription.rb +++ b/app/models/subscription.rb @@ -32,7 +32,7 @@ class Subscription < ApplicationRecord { target_id: source.id, target_type: Comment, recipient_id: s.user_id, new: true, type: Notification::Commented } end - Notification.insert_all!(notifications) # rubocop:disable Rails/SkipsModelValidations + Notification.insert_all!(notifications) unless notifications.empty? # rubocop:disable Rails/SkipsModelValidations end def denotify(source, target)