Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
Captcha
=======
It is captcha varification plugin for Rails applications. It creates random images and random text written over the
images and validates the captcha text after the submition of the form.
Installation
============
Captcha installation process.
MiniMagick installation :
sudo gem install mini_magick
Plugin installation :
script/plugin install git://github.com/hokam/captcha.git
Uninstallation
==============
script/plugin remove captcha
Usage
=====
After installation process you need to add 'before_filter' callback in your controller to create captcha image before
the processing of specified actions.
Suppose you have a CommentsController in which you want to create capthca image for "new" action so just add the following
lines in your controller.
class CommentsController << ActionController::Base
before_filter :create_captcha, :only => [:new]
# ....
# ....
end
And for validation of captcha text you need to call validate_captcha funtion in the required action.
Lets say in "create" action of CommentsController you want to apply captcha validation, so do the following addition
in your 'create' action.
class CommentsController << ActionController::Base
before_filter :create_captcha, :only => [:new]
def new
# action related data
end
# other action methods
def create
if validate_captcha
# ........
else
# ........
end
end
end
And add the following line in your html view to create captcha image.
<%= image_captcha_tag %>
If captcha validation failes then captcha plugin set the error message
in flash[:notice] variable, so you should use flash[:notice] variable in
your form for the notification of captcha failure message.
<%= flash[:notice] if flash[:notice] %>
To read more, use following.
http://rails-plugin-usage.blogspot.com/2011/06/rails-catpcha-plugin-usage.html