Installations
At first you have to install RMagick package by command (example for Debian system):
aptitude install librmagick-ruby
Then install Magick-captcha plugin (run from root project directory):
ruby script/plugin install http://github.com/greyblake/magick-captcha.git
Usage
# controller
def new
@user = User.new
generate_captcha_for @user
end
def create
@user = User.new(params[:user])
validates_captcha_of(@user)
@user.save
end
# view
<%= text_field :user, :captcha %>
<%= captcha_image %>
Also you can use some options in a controller:
generate_captcha_for @user, :bg_color => "#00FF00",
:color => "#000000", :length => 8
- bg_color - background color of captcha image
- color - color of text
- length - length of capcha string(characters)