models: fix deprecated errors[:base] << "message" calls.

Replace the idiom `errors[:base] << "message"` with
`errors.add(:base, "message")`. The former is deprecated in Rails 6.1.
This commit is contained in:
evazion
2020-12-13 04:00:32 -06:00
parent 62b69eb133
commit 8d87b1a0c0
29 changed files with 108 additions and 109 deletions

View File

@@ -26,13 +26,13 @@ class Note < ApplicationRecord
extend SearchMethods
def validate_post_is_not_locked
errors[:post] << "is note locked" if post.is_note_locked?
errors.add(:post, "is note locked") if post.is_note_locked?
end
def note_within_image
return false unless post.present?
if x < 0 || y < 0 || (x > post.image_width) || (y > post.image_height) || width < 0 || height < 0 || (x + width > post.image_width) || (y + height > post.image_height)
self.errors.add(:note, "must be inside the image")
errors.add(:note, "must be inside the image")
end
end