From 4f88b82361cc4c874a111e4120f40a454b6d241e Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sun, 17 Jul 2022 21:03:23 +0200 Subject: [PATCH] Use null-safe navigation for `denotify` --- app/models/answer.rb | 2 +- app/models/appendable/reaction.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/answer.rb b/app/models/answer.rb index f0d12326..4af3b5ee 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -38,7 +38,7 @@ class Answer < ApplicationRecord comment.user&.decrement! :commented_count Subscription.denotify comment, self end - Notification.denotify self.question.user, self + Notification.denotify question&.user, self Subscription.destruct self end # rubocop:enable Rails/SkipsModelValidations diff --git a/app/models/appendable/reaction.rb b/app/models/appendable/reaction.rb index 06872ce9..97de8963 100644 --- a/app/models/appendable/reaction.rb +++ b/app/models/appendable/reaction.rb @@ -9,7 +9,7 @@ class Appendable::Reaction < Appendable end before_destroy do - Notification.denotify parent.user, self + Notification.denotify parent&.user, self user&.decrement! :smiled_count parent&.decrement! :smile_count end