【问题标题】:How to initialize recaptcha in rails app?如何在rails应用程序中初始化recaptcha?
【发布时间】:2013-08-18 15:10:24
【问题描述】:

我使用了以下指南:http://www.tweetegy.com/2012/10/setting-up-a-captcha-with-recaptcha-service-and-the-captcha-gem/

我在 development.rb 中有以下内容:

ENV['RECAPTCHA_PUBLIC_KEY'] = 'keyString'
ENV['RECAPTCHA_PRIVATE_KEY'] = 'keyString'

在 config/initializers/recaptcha.rb 中:

Recaptcha.configure do |config|
  config.public_key  = RECAPTCHA_PUBLIC_KEY
  config.private_key = RECAPTCHA_PRIVATE_KEY
end

在开发中运行 rails server 时出现以下错误:

Exiting                                                                                                                                           
/home/action/visualhaggard.org/config/initializers/recaptcha.rb:2:in `block in <top (required)>': uninitialized constant RECAPTCHA_PUBLIC_KEY (Nam
eError)

有没有人遇到并解决过这个问题?我有错字吗?谢谢。

【问题讨论】:

    标签: ruby-on-rails recaptcha


    【解决方案1】:

    该示例未在环境变量中定义 RECAPTCHA_PUBLIC_KEY。它只是将它定义为一个常量。

    #put this in development.rb and in production.rb (separate keys in each so you can test!)
    RECAPTCHA_PUBLIC_KEY= 'your-public-key'
    RECAPTCHA_PRIVATE_KEY= 'your-private-key'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-20
      • 2013-04-06
      • 1970-01-01
      • 2013-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多