[英]Rails 3: Recaptcha name error
使用reCaptcha在表單上按Submit時出現此錯誤:
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'方法? 有人知道解決方法嗎?
我相信該方法稱為verify_recaptcha
,而不是verify_captcha
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.