Captcha code verification has the following advantages.
- Prevention against fake comment spams which are posted on some blog.
- Avoids thousands of sign up on free email services via bots.
- Assures that only humans can fill the feedback and survey forms.
- Prevents the attack of machine programs to break the passwords.
If you don’t have mini_magick on your system, use following
command to install mini_magick.
|sudo gem install mini_magick|
Just run following command from application root directory.
|script/plugin install git://github.com/hokam/captcha.git|
Captcha Plugin Uninstallation Process.
Just run following command from application root directory to
remove captcha plugin.
|script/plugin remove captcha|
How to Use Captcha plugin ?
After installation process you need to add ‘before_filter’ callback in your controller to create captcha image before the processing of specified actions.
|before_filter :create_captcha, :only => [:new]|
And add the following line in your form to include captcha image.
|<%= image_captcha_tag %>|
This tag generates an image with text, a link to change the captcha
image and a text box for the input of captcha text written over the
|class CommentsController << ActionController::Base
before_filter :create_captcha, :only => [:new]
# action specific data
# other actions
If captcha validation fails 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] %>|
So by using this plugin, ruby application can be easily prevented from
the fake form fillings, thousands of sign up in a minutes via bots,
password hacking by machine programs, spam attacks and malicious