GithubHelp home page GithubHelp logo

elevation / filters_spam Goto Github PK

View Code? Open in Web Editor NEW

This project forked from resolve/filters_spam

0.0 4.0 0.0 237 KB

Spam filter mixin for your models. Purposed for Refinery CMS but we'll see if we can make it generic.

Home Page: http://refinerycms.com

Ruby 100.00%

filters_spam's Introduction

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 Gemfile
gem 'filters_spam', '~> 0.3'

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

filters_spam's People

Contributors

djones avatar parndt avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.