Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Spam filter mixin for your models. Purposed for Refinery CMS but we'll see if we can make it generic.
Ruby
Branch: master

Merge pull request #5 from parndt/patch-1

Syntax highlighting!!!!!!!!!
latest commit 6b2b190a2c
@ugisozols ugisozols authored
Failed to load latest commit information.
lib Use current AR query syntax.
filters_spam.gemspec Incremented version number
readme.md Syntax highlighting!!!!!!!!!

readme.md

FiltersSpam

This is a small Ruby on Rails plugin that can be installed as a gem in your Gemfile that allows models to attach to it to provide spam filtering functionality.

Rails Quickstart

Add to your Gemfile:

gem 'filters_spam', '~> 0.4'

Run bundle install.

Usage

Once you have the plugin installed, you need to add a column to the table you will be using this for. For example, if you have a table called comments:

script/generate migration add_spam_to_comments spam:boolean
rake db:migrate

The same thing in Rails 3:

rails generate migration add_spam_to_comments spam:boolean
rake db:migrate

Now, you can use it by calling the function in your model like so:

filters_spam

If you want to change the default fields that are used by filters_spam then you can pass them in to the method as options. All options are optional.

All of the possible options are outlined below with the default values for each:

filters_spam({
  :message_field => :message,
  :email_field => :email,
  :author_field => :author,
  :other_fields => [],
  :extra_spam_words => %w()
})

So, say you wanted to mark 'ruby' and 'rails' as spam words you simply pass them in using the :extra_spam_words option:

filters_spam({
  :extra_spam_words => %w(ruby rails)
})

Enjoy a life with less spam.

Credits

This code was inspired by Russel Norris' acts_as_snook plugin and ideas presented by Jonathan Snook

Something went wrong with that request. Please try again.