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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user