3

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

どういうわけか、recaptcha について simple_form にもっと何かを伝える必要があると思いますが、.error_notification に関する多くの情報を見つけることができません。

助けてくれてありがとう!

4

1 に答える 1

2

コントローラーで:

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>

変数を使用してエラー メッセージを表示できます。

于 2016-03-01T05:28:52.870 に答える