Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
captcha for Rails
Ruby
branch: master

This branch is 34 commits ahead, 73 commits behind galetahub:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app/controllers
config
lib
test
.gitignore
README.md
README_1.rdoc
Rakefile
VERSION
init.rb
wxianfeng_simple_captcha.gemspec

README.md

SimpleCaptcha

captcha for Rails

原理

simple_captcha 的原理是把生成的 key放到session中,key对应的value存到数据库中,到后端进行比对即可

Requirements

  • ImageMagick

Install

Rails < 3.1

gem 'wxianfeng_simple_captcha', '0.1.0', require: 'simple_captcha' 

Rails >=3.1

gem 'wxianfeng_simple_captcha', '0.2.0', require: 'simple_captcha' 

Rails >=4.0

gem 'wxianfeng_simple_captcha', '0.5.0', require: 'simple_captcha'

Setup

rails generate simple_captcha 
rake db:migrate 

Usage

controller:

 include SimpleCaptcha::ControllerHelpers 

view:

 <%= show_simple_captcha %> 

controller valid:

if simple_captcha_valid? 
 "OK!" 
else
 'Fail!'
end

DEMO

http://d.wxianfeng.com/demos/simple_captcha

Something went wrong with that request. Please try again.