Announcing Profanity Filter for Rails

I’m pleased to announce Profanity Filter for Rails. This gem filters undesirable words from text and displays a friendly version. Filtering is non-destructive by default but has the option of replacing the original text. It’s based on a dictionary that is customizable so you can add additional words as needed.

Profanity Filter is the evolution of a plugin I created a few years ago called Fu-Fu (the Profanity Filter for Rails). This new version has been renamed, tested with Rails 3 and has been moved over to the Intridea github account to ensure proper support (bug fixing, development time, etc) going forward.


gem install profanity_filter

Rails 3 with Bundler

Open your Gemfile and add:

gem "profanity_filter"

Rails 2.x without Bundler

Open config/environment.rb and add:

config.gem "profanity_filter"

Usage: Basic

You can call the profanity_filter method within your ActiveRecord models.

Usage: Non-Destructive

Filters content when called, original text remains in the database.

Usage: Destructive

Filters content in the database, original text is lost. Note the “!” when calling the profanity_filter method.

You can find additional information in the README.


I’ve used this on a number of projects and it’s served me well but it’s by no means perfect. If you find something that doesn’t work for you or have a suggestion please let me know and I’ll see what I can do (directly or through Github Issues). If you have an improvement/refactoring I welcome pull requests on Github. The project has a full test suite with benchmarking and the code base is tiny so feel free to jump in!

You can find Profanity Filter on Intridea’s Github account.