diff options
author | Benjamin Neff <benjamin@coding4coffee.ch> | 2022-08-01 00:10:38 +0300 |
---|---|---|
committer | Benjamin Neff <benjamin@coding4coffee.ch> | 2022-08-01 00:12:00 +0300 |
commit | 9485a0263985a5c2a41446e020e02c2accabc2bb (patch) | |
tree | 01bf7a345b4cc80009586c8832ff2a5fdb905a8a /app/models/report.rb | |
parent | 02eba842aed40e6411fbed8db9e32fcd0e59c642 (diff) | |
parent | eaedd3d26ca7e993e42fba02bc4e4fc5e72ae73e (diff) |
Merge branch 'next-minor'v0.7.18.0
Diffstat (limited to 'app/models/report.rb')
-rw-r--r-- | app/models/report.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/app/models/report.rb b/app/models/report.rb index ab169e7f1..1da8c4b24 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -22,15 +22,15 @@ class Report < ApplicationRecord end def entry_does_not_exist - if Report.where(item_id: item_id, item_type: item_type).exists?(user_id: user_id) - errors[:base] << 'You cannot report the same post twice.' - end + return unless Report.where(item_id: item_id, item_type: item_type).exists?(user_id: user_id) + + errors.add(:base, "You cannot report the same post twice.") end def post_or_comment_does_exist - if Post.find_by_id(item_id).nil? && Comment.find_by_id(item_id).nil? - errors[:base] << 'Post or comment was already deleted or doesn\'t exists.' - end + return unless Post.find_by(id: item_id).nil? && Comment.find_by(id: item_id).nil? + + errors.add(:base, "Post or comment was already deleted or doesn't exists.") end def destroy_reported_item |