简体   繁体   English

如何让Ambethia Recaptcha与simple_form .error_notification一起使用?

[英]How do I get Ambethia Recaptcha to work with simple_form .error_notification?

I love the new .error_notification feature in simple_form, but I have no idea how to include my recaptcha in it. 我喜欢simple_form中新的.error_notification功能,但我不知道如何在其中包含我的recaptcha。 The code I have looks like: 我的代码看起来像:

<%= simple_form_for(resource, :as => resource_name, :url =>      registration_path(resource_name)) do |f| %>
  <%= f.error_notification %>
  <div class="form-inputs">
    <%= f.input :email, :required => true, :autofocus => true %>
    <%= f.input :password, :required => true %>
    <%= recaptcha_tags %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Sign up" %>
  </div>
<% end %>

I imagine I need to somehow tell simple_form something more about the recaptcha but I can't find much information about .error_notification. 我想我需要以某种方式告诉simple_form更多关于recaptcha的信息,但我找不到关于.error_notification的更多信息。

Thanks for any help! 谢谢你的帮助!

In controller: 在控制器中:

unless verify_recaptcha
   @captcha_error="Word verification response is incorrect"
end

In view: 在视图中:

<%= recaptcha_tags %>
<span class="help-block pull-left" style="color:#a94442;"><%=@captcha_error%></span>

You can use variable to show your error message. 您可以使用变量来显示错误消息。

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

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