繁体   English   中英

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

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

我喜欢simple_form中新的.error_notification功能,但我不知道如何在其中包含我的recaptcha。 我的代码看起来像:

<%= 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 %>

我想我需要以某种方式告诉simple_form更多关于recaptcha的信息,但我找不到关于.error_notification的更多信息。

谢谢你的帮助!

在控制器中:

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

在视图中:

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

您可以使用变量来显示错误消息。

暂无
暂无

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

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