mini_captcha
recently published a minimalistic captcha plugin for rails applications...

mini_captcha is a minimalistic captcha plugin for rails projects, based on some code developed for a friend’s website.
developing another captcha plugin (there are a few other plugins out there) was inspired by the spirit of minimalism:

  • not to store images in the db
  • not to keep images with any of the models that might need captcha protection when creating instances
  • keep images only as long as needed (serve once, delete)

HOWTO

To install and integrate to your rails website, follow these steps:

  1. install RMagick and Digest — if not yet installed
  2. install mini_captcha:

    script/plugin install git@github.com:srejbi/mini_captcha.git
  3. add the following lines to your application controller:

    require 'vendor/plugins/mini_captcha/lib/mini_captcha' include MiniCaptcha::ControllerHelpers
  4. add a map to the MiniCaptcha controller for the MiniCaptcha image display

    map.mini_captcha '/mini_captcha/:action', :controller => 'mini_captcha', :action => 'show_image'
  5. add a div like this to any view you want to protect with MiniCaptcha from spam:

    ... (your page & form)... <div class="..."><%= show_mini_captcha %> </div> ... (your page) ....
  6. update the processing controller similarly to the following block:

    if @form.valid? your original validation if mini_captcha_valid? extend it with checking the MiniCaptchaChallenge do whatever... flash[:notice] = 'Your form input was correct.' redirect as you wish else belongs to your new validation of MiniCaptchaChallenge (failure branch) flash[:error] = 'Failed MiniCaptcha Challenge.' punish the 'bot, piss off the user (just kidding ;)) end end of yout new block for MiniCaptchaChallenge failure end
  7. enjoy getting less spam, more real comments :-)

Credits: thanks to milkfarm for specs, ideas, and actual updates on the code.

for more details and updates, visit the project page on GitHub

0 comments
New Comment







mini_captcha.png