Use `length` validation instead of `presence` for `MuteRule`
This commit is contained in:
parent
d40519dffa
commit
f3f8e99045
|
@ -3,7 +3,7 @@
|
||||||
class MuteRule < ApplicationRecord
|
class MuteRule < ApplicationRecord
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
|
||||||
validates :muted_phrase, presence: true
|
validates :muted_phrase, length: { minimum: 1 }
|
||||||
|
|
||||||
def applies_to?(post)
|
def applies_to?(post)
|
||||||
!!(post.content =~ /\b#{Regexp.escape(muted_phrase)}\b/i)
|
!!(post.content =~ /\b#{Regexp.escape(muted_phrase)}\b/i)
|
||||||
|
|
Loading…
Reference in New Issue