简体   繁体   English

在Rails 2.3.12中使用reCaptcha

[英]Using reCaptcha with Rails 2.3.12

So I'm trying to get reCaptcha to render on a partial form view that uses HAML. 因此,我试图让reCaptcha呈现在使用HAML的部分表单视图上。 I have tried using the :ruby filter and then adding <%= recaptcha_tags %> but that didn't work, neither has anything else that I've found. 我试过使用:ruby过滤器,然后添加<%= recaptcha_tags %>但这没有用,也没有找到任何其他东西。 Is there a way to implement this? 有办法实现吗?


*Revision *修订


Ahem, more specifically, can anyone tell me what I need to have for the <%= recaptcha_tags %> helper? 更具体地讲,Ahem,有人可以告诉我<%= recaptcha_tags %>助手需要的东西吗? Every thing I find on this subject just says "Add <%= recaptcha_tags %> wherever you want it to appear!" 我在该主题上发现的所有内容都只是说“添加<%= recaptcha_tags %>无论您希望它出现在何处!” and absolutely nothing on what the helper should contain. 绝对没有关于助手应该包含的内容的信息。


*Another Revision *另一次修订


I am indeed trying to use Ambethia. 我确实在尝试使用Ambethia。 I tried using just = recaptcha_tags but that didn't work, I got an error saying it was an undefined variable or method. 我尝试使用just = recaptcha_tags但是没有用,我收到一条错误消息,说它是未定义的变量或方法。 I installed the Ambethia/reCaptcha as a plugin using script/plugin install git://github.com/ambethia/recaptcha.git and I put config.gem "ambethia-recaptcha", :lib => "recaptcha/rails", :source => "http://gems.github.com" in environment.rb along with my public/private keys. 我使用script/plugin install git://github.com/ambethia/recaptcha.git将Ambethia / reCaptcha安装为插件,然后将config.gem "ambethia-recaptcha", :lib => "recaptcha/rails", :source => "http://gems.github.com"environment.rb以及我的公共/私有密钥。


*Started Over *重新开始


Okay, got rid of everything I had done initially. 好的,摆脱掉我最初所做的一切。 Can anyone help me with this? 谁能帮我这个? I follow all of the tutorials I can find on it, but none of them explain how to implement/create the helpers for <%= recaptcha_tags %> or <%= verify_recaptcha %> . 我遵循了所有可以找到的教程,但是没有一个教程解释如何实现/创建<%= recaptcha_tags %><%= verify_recaptcha %> I'm obviously new to RoR and implementing reCaptcha of any kind, so I'm sorry I'm asking for my hand to be held but I am honestly lost and am not finding any guidance anywhere! 我显然对RoR并不陌生,并且不知道要执行任何形式的reCaptcha,所以很抱歉,我要求握住我的手,但老实说我迷路了,在任何地方都找不到任何指导! Thanks so much anyone and everyone. 非常感谢所有人。

did you try simply: 您是否尝试过简单地:

= recaptcha_tags

You don't mention the plugin you're using. 您没有提及您正在使用的插件。 I'm assuming this one . 我假设这个 If that's the case, the recaptcha_tags helper will return the HTML for the captcha, and you'd insert it into whichever forms you wanted the captcha to appear on. 在这种情况下, recaptcha_tags帮助程序将返回验证码的HTML,然后将其插入希望显示验证码的任何形式。

The <%= %> around recaptcha_helper aren't part of the helper, but rather the way you insert content into erb templates (and other templating languages resembling erb). recaptcha_helper周围的<%= %>不是帮助程序的一部分,而是将内容插入erb模板(以及与erb类似的其他模板语言)的方式。 In Haml you don't need the surrounding tag. 在Haml中,您不需要周围的标签。 It's just = . 只是=

I had the same problem and I finally solved it realizing that my form was called asynchronously. 我遇到了同样的问题,最终意识到我的表单被异步调用了,我终于解决了。

I added: 我补充说:

= recaptcha_tags :ajax => true = recaptcha_tags:ajax => true

and captcha appeared. 验证码出现了。

Hope this could help the original question. 希望这可以帮助原来的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM