为什么我的 RoR Ambethia Recaptcha 插件/gem 可能只返回 false?
显示我的表单显示的视图
<%=raw recaptcha_tags %>
控制器我需要检查 recaptcha
if verify_recaptcha && @question.save
...
else
flash[:error] = "Incorrect word verification. Are you sure you're human?"
redirect_to :back
end
无论如何, 'verify_recaptcha' 返回 false,因此表单发布不成功。
I'm trying to set up Recaptcha in my Ruby-on-Rails app (Rails 3), using Ambethia's plugin or gem. After I install the plugin or gem and set up my public and private keys in a config/initializers/recaptcha.rb, I use it like this:
show view where my form is displayed
<%=raw recaptcha_tags %>
controller where I need to check the recaptcha
if verify_recaptcha && @question.save
...
else
flash[:error] = "Incorrect word verification. Are you sure you're human?"
redirect_to :back
end
No matter what, 'verify_recaptcha' returns false and so the form posting doesn't succeed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看这个 Rails 3 示例:
check out this Rails 3 example:
刚刚找到了我的问题的答案。由于超时,我得到了错误的验证码。在 verify.rb 中,有一个块正在继续发送到 API,并且它取决于超时,可以在 verify() 调用的参数中设置。而且我认为我的 inet 太慢,这就是为什么 3 还不够。我调用了 verify(:timeout => 50) 并且它工作得很好。
Just found the answer for my problem. I got wrong recaptcha because of timeout. In verify.rb there is a block where posting to API is proceeding, and it is depending on timeout, that can be set in params of verify() call. And I think that my inet is too slow that's why 3 wasn't enough. I called verify(:timeout => 50) and it worked perfectly.