【问题标题】:Rails 3: Recaptcha name errorRails 3:Recaptcha 名称错误
【发布时间】:2012-08-11 02:17:16
【问题描述】:

使用 reCaptcha 在我的表单上按提交时出现此错误:

NameError in PostsController#create

undefined local variable or method `verify_captcha' for #<PostsController:0x007fcf52e84b48>

我安装了 gem,其中包含从 recaptcha 网站注册的私钥和公钥以及配置文件中的密钥。我已经运行了“捆绑安装”。验证码适用于表单,因为我可以刷新新代码。

#gemfile
 gem "recaptcha", :require => "recaptcha/rails"

#controller
    respond_to do |format|
          if verify_captcha and @post.save
            format.html { redirect_to @post, notice: 'Post was successfully created.' }

          else
            format.html { render action: "new" }         
          end
        end

为什么 rails 不能识别 Recaptcha gem 库中的“verify_captcha”方法?有谁知道解决办法吗?

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 recaptcha


    【解决方案1】:

    我相信该方法称为verify_recaptcha,而不是verify_captcha

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多