No release in over 3 years
Low commit activity in last 3 years
Spam detection plugin for Rails 2 & ActiveRecord 2. Uses all the standard Rails conventions and my Despamilator gem. Use the main (non rails2) version for Rails 3.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.8.0

Runtime

 Project Readme

despamilator_rails¶ ↑

DESCRIPTION:¶ ↑

Spam detection plugin for Rails & ActiveRecord. Uses all the standard Rails conventions and my Despamilator gem. This gem only supports Rails 3. See despamilator_rails2 for Rails 2 support.

FEATURES/PROBLEMS:¶ ↑

SYNOPSIS:¶ ↑

Somewhere (such as your environment.rb…)

require 'despamilator_rails'

In your model (basic example):

class YourModel < ActiveRecord::Base
  validate_with_despamilator :attributes => [:some_field]
end

When “some_field” is assigned a spammy value, it will add to the errors. For example…

YourModel.new(:some_field => spammy_value).save! #=> ActiveRecord::RecordInvalid exception!

Or…

your_instance = YourModel.new(:some_field => spammy_value)
your_instance.save
your_instance.errors.full_messages.should #=> ["Some field looks like spam"]

If you want to configure the threshold (which defaults to 1) or add your own callback, you can do the following:

class YourModel < ActiveRecord::Base
  validate_with_despamilator :attributes => [:some_field], :threshold => 1 do |field, value, despamilator|
    raise "spam! field: #{field}, value: #{value}, score: #{despamailtor.score}"
  end
end

This example will…

your_instance = YourModel.new(:some_field => "spammy string")
your_instance.save! #=> Exception "spam! field: some_field, value: spammy string, score: 123"

The callback will receive the field name, the value and the instance of the Despamilator class.

See the various examples in “spec/fixtures”.

REQUIREMENTS:¶ ↑

  • ActiveRecord >= 2.3.2

  • Despamilator >= 1.0

INSTALL:¶ ↑

  • gem install despamilator_rails

LICENSE:¶ ↑

(The MIT License)

Copyright © 2011 Stephen Hardisty

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.