如何在注册时将验证码与设计集成?

jpw*_*ynn 12 captcha ruby-on-rails devise

我假设有一些相当直接的方法将Captcha添加到使用Devise进行身份验证的rails3应用程序,但我找不到任何关于如何将验证码"连接"到注册过程的示例.

我在这里看到了几个主题,但他们讨论的是'为什么'而不是'如何'.

任何尖头都会有所帮助!

小智 18

看一下以下指南,它有一个reCAPTCHA的实现:

https://github.com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise

  def create
    if method_to_check_captcha
      super
    else
      build_resource
      clean_up_passwords(resource)
      flash[:error] = "There was an error with the captcha code below. Please re-enter the code and click submit."
      render_with_scope :new
    end
  end
Run Code Online (Sandbox Code Playgroud)

从那里,只需编程方法来检查验证码.