Prevent errors in `User#answer` when asking anonymous questions

This commit is contained in:
Karina Kwiatek 2022-06-13 19:31:37 +02:00
parent 14e84fd47c
commit b657894576
1 changed files with 1 additions and 1 deletions

View File

@ -107,7 +107,7 @@ class User < ApplicationRecord
# @param content [String] the answer content
def answer(question, content)
# rubocop:disable Style/RedundantSelf
raise Errors::AnsweringOtherBlockedSelf if question.user.blocking?(self)
raise Errors::AnsweringOtherBlockedSelf if question.user&.blocking?(self)
raise Errors::AnsweringSelfBlockedOther if self.blocking?(question.user)
# rubocop:enable Style/RedundantSelf