comments: change error message when body is blank.

Change error from "Body has no content" to "Body can't be blank" when a
user tries to submit an empty comment. This makes it consistent with
error messages in other models when someone tries to submit blank content.
This commit is contained in:
evazion
2021-03-07 19:25:44 -06:00
parent 4b61a9c73c
commit e6a501393a

View File

@@ -1,11 +1,13 @@
class Comment < ApplicationRecord
validates_presence_of :body, :message => "has no content"
belongs_to :post
belongs_to :creator, class_name: "User"
belongs_to_updater
has_many :moderation_reports, as: :model
has_many :votes, :class_name => "CommentVote", :dependent => :destroy
validates :body, presence: true
before_create :autoreport_spam
after_create :update_last_commented_at_on_create
after_update(:if => ->(rec) {(!rec.is_deleted? || !rec.saved_change_to_is_deleted?) && CurrentUser.id != rec.creator_id}) do |rec|