Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/report.rb')
-rw-r--r--app/models/report.rb12
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