validates_not_profane provides a hook into the Profanalyzer gem as a validation for your ActiveRecord models. It's use is simple:
validates_not_profane :column_name, :column_2
Will cause the model to produce errors if that column contains profanity in its value. Of course, since the Profanalyzer gem is customizable, so is the validation:
validates_not_profane :post_title, :racist => true, :sexual => false
will block racial slurs, but nothing else.
validates_not_profane :post_title, :tolerance => 5
will block only the most vile of profanity. The scale for tolerance is from 0-5, which is mostly subjective, in all honesty.
You can also use the :label option to customize the error message - see the examples in the README.
No comments:
Post a Comment