The samples directory contains an example of using Ruby/CAPTCHA on a web page.
1) [optional] Create a configuration file that contains the options you want
the CAPTCHA to use. (See the captcha.conf file in the samples subdirectory
for an example).
2) require 'captcha' (or, require_gem 'captcha' if using RubyGems)
3) Instantiate a CAPTCHA::Web object, either directly, with 'new', or from
a configuration file, with 'from_configuration'.
4) Call CAPTCHA::Web#clean, to clean out any stale key images from the images
directory.
5) Call CAPTCHA::Web#to_html to create the image file (which gets copied to
the configured images directory) and to return the HTML snippet (as defined
by the configured template). The HTML snippet should go on the page where
you wish the image and the form to be displayed.
6) After the form is submitted, get the user's input and the previously generated
'digest' value (from the form fields) and call CAPTCHA::Web.is_valid( key, digest )
to determine if the user's input matches the previously generated digest. If not,
they didn't enter the key correctly. Otherwise, they did. |