簡體   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