Yacaph

Yacaph (pronounced "Yakaf") stands for "Yet Another CAPtcha Helper". I wanted to use the shorter name "Yach" but it seems that it's a reserved name for Rails! What makes Yakaph different from other captcha helpers? Raw speed.

The following strategies are used to make this implementation efficient and scalable:

  1. Captcha images are generated offline using a rake task.
  2. It's stateless and does not require session data.
  3. It looks good on almost any background color.

Here is a screenshot

screenshot

Using Yacaph is a five step process:

  1. Install the RMagick
  2. Install the plugin
  3. Generate captcha images
  4. Use helper methods to present the captcha
  5. Use helper methods to validate input

Links:

Other Similar Rails Plugins:



1. Install RMagick

I won't tell you how to do this here but I will point you to the instructions.

2. Install the Plugin

To install the plugin all you need to do is issue the following command from the root directory of your rails application:

script/plugin install svn://rubyforge.org/var/svn/yacaph/trunk

3. Generate captcha images

To make this as simple as possible, I've written a rake task to do this. It's quite time consuming to do so kick back and relax while it's doing it's thing. Perhaps, you'll want to reduce the number of images if you only want to test the plugin. Run the following task to generate 250 random images.

rake yacaph:generate COUNT=250

This will create the /public/images/captcha directory if it does not already exist and will put 250 freshly generated gifs in there. These images use tranparency effects so that they blend well with almost any background color expecpt one that are too dark. It should not be too difficult to adapt the code to produce images for dark backgrounds.

4. Use helper methods to present the captcha

In your forms all you need to do is:


  <%= yacaph_block %>

Don't forget to add a little bit of CSS styling to get a nice looking captcha validation text field and image. If you don't like the way it's setup then use the other helper methods, which are more granular.

5. Use helper methods to validate input

In your controller, you will need to do the following:


PostController < ApplicationController

   include YacaphHelper

   def create
      ...
      if yacaph_validated?
         ...
      else
         ...
      end
   end
end

That's it. Did I tell you that it flies?

Enjoy!