UX: when a post is blocked due to a watched word, message includes the word being blocked

This commit is contained in:
Neil Lalonde
2018-02-28 11:22:04 -05:00
parent e7a7356986
commit baf1c385eb
4 changed files with 6 additions and 6 deletions

View File

@ -58,8 +58,8 @@ class Validators::PostValidator < ActiveModel::Validator
end
def watched_words(post)
if !post.acting_user&.staff? && !post.acting_user&.staged && WordWatcher.new(post.raw).should_block?
post.errors[:base] << I18n.t('contains_blocked_words')
if !post.acting_user&.staff? && !post.acting_user&.staged && matches = WordWatcher.new(post.raw).should_block?
post.errors[:base] << I18n.t('contains_blocked_words', word: matches[0])
end
end