Antivirus provides a validator which filter profane words for Rails application.
Add this line to your application's Gemfile:
And then execute:
Define profane words as array in
antivirus.message key is an error message when value includes profane words.
en: antivirus: message: includes profane words. profane_words: - foo - bar - baz
For example, Post model exists like this:
class Post < ActiveRecord::Base validates :content, profanity_filter: true end
In this case,
post can't include profane words.
post = Post.create(content: 'foo') post.valid? #=> false post.errors.full_messages #=> ["Content includes profane words."]
- Fork it ( https://github.com/kami-zh/antivirus/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request