From afe391472a8b9297939b7b4a403c3ea139275020 Mon Sep 17 00:00:00 2001 From: Aga Dufrat Date: Wed, 29 Jan 2025 13:08:50 +0000 Subject: [PATCH] Refactor to use update! Replaced update with update! to raise an exception in case of validation failure, as suggested by the Rails/SaveBang RuboCop rule. This ensures that any issues with updating the problem_report are explicitly handled by raising an exception. --- .../anonymous_feedback/problem_reports_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/anonymous_feedback/problem_reports_controller.rb b/app/controllers/anonymous_feedback/problem_reports_controller.rb index ca356d46..002bec03 100644 --- a/app/controllers/anonymous_feedback/problem_reports_controller.rb +++ b/app/controllers/anonymous_feedback/problem_reports_controller.rb @@ -74,9 +74,9 @@ def mark_supplied_reports_as_reviewed_and_spam review_attrs = { reviewed: true, marked_as_spam: } - problem_report.update(review_attrs) + problem_report.update!(review_attrs) end - rescue ActiveRecord::RecordNotFound + rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid false end