Rails captcha in ubuntu system
2013-11-29 14:38
387 查看
Use rails scale to init the captcha.
I use a gem called simple_captcha , before you use this gem , first you must install the imagemagick , for the save , tap the command below:
Then add a line in the rails dir's Gemfile:
Init the simple_captcha config:
If there is no error , the rest option will so simple .
Include the helper in the application_comtroller.rb
In the view file :
In the controller action:
For more information , please read the README file in this site : https://github.com/galetahub/simple-captcha
I use a gem called simple_captcha , before you use this gem , first you must install the imagemagick , for the save , tap the command below:
sudo apt-get install imagemagick sudo apt-get install libmagickcore-dev sudo apt-get install libmagickwand-dev
Then add a line in the rails dir's Gemfile:
gem 'simple_captcha', :git => 'git://github.com/galetahub/simple-captcha.git'
bundle install
Init the simple_captcha config:
SimpleCaptcha.setup do |captcha_config| captcha_config.tmp_path = Rails.root + 'tmp' captcha_config.image_style = 'simply_red' end
If there is no error , the rest option will so simple .
Include the helper in the application_comtroller.rb
class ApplicationController < ActionController::Base include SimpleCaptcha::ControllerHelpers end
In the view file :
<p><%= @output %></p> <form method="get" action="" > <%= show_simple_captcha(:label => 'enter',:placeholder=>'place')%> <input type="submit" value="submit" /> </form>
In the controller action:
if simple_captcha_valid? @output = 'right' else @output = 'error' end
For more information , please read the README file in this site : https://github.com/galetahub/simple-captcha
相关文章推荐
- 在gem5的full system下运行 alpha编译的测试程序 running gem5 on ubuntu in full system mode in alpha
- Ubuntu16.04出现the system is running in low-graphics mode时解决方法
- Ubuntu下 安装NVIDIA驱动(循环登陆+开机显示the system is running in low graphic mode问题 )
- Simple Captcha in rails 3
- Ubuntu系统启动报错:The system is running in low-graphics mode
- ubuntu 14.4 安装开机后报the system is running in low-graphics mode错误
- 虚拟机Ubuntu16.04无法进入图形界面 The system is running in low-graphics mode
- How install mysql in Ubuntu for Rails 3
- [Ubuntu] this system is running in low-graphics mode
- 升级ubuntu 14.04,出现The system is running in low-graphics mode解决方法
- ubuntu 16.04 虚拟机 “The system is running in low-graphics mode”
- Adding a Custom System Call to Ubuntu Linux in [C]
- How to install Android SDK in Ubuntu System
- Ubuntu系统启动报错:The system is running in low-graphics mode
- Ubuntu 12.04 the system is running in low-graphics mode 解决方法
- ubuntu the system is running in low-graphics mode 解决办法
- 在gem5的full system下运行 alpha编译的测试程序 running gem5 on ubuntu in full system mode in alpha
- Ubuntu 出现The system is running in low-graphics mode解决
- No Language-Support in system setting ,Ubuntu
- ubuntu启动失败the system is running in low graphics mode