デバイス登録のエラー メッセージに問題があります。私のカスタム デバイス コントローラーには、検証の失敗時にリソースを返す create メソッドがあります。何らかの理由で、サインアップ ページがレンダリングされると、resource.errors がクリアされます。誰かがこの問題に遭遇しましたか? dm-devise 2.1.0 を使用しています
それが役立つ場合、これが私のコードです:
class UserDevise::RegistrationsController < Devise::RegistrationsController
def create
begin
build_resource
....
rescue DataMapper::SaveFailureError => e
resource = e.resource
clean_up_passwords(resource)
respond_with resource
end
end
end
編集: 要求された clean_up_passwords のコードは次のとおりです (Devise によって定義されています)。
def clean_up_passwords(object)
object.clean_up_passwords if object.respond_to?(:clean_up_passwords)
end
def clean_up_passwords
self.password = self.password_confirmation = nil
end
EDIT2:サインアップページのビューコードは次のとおりです。
<div class="account-container">
<div class="content clearfix">
<%= simple_form_for resource, :html => {:class => 'form-vertical'}, :url => registration_path(resource_name) do |f| %>
<h1>Create Account</h1>
<div class="login-fields">
<p>Please provide the following info:</p>
<%= f.input :name, :placeholder => "Full Name", :input_html=>{:class => "login username-field"} %>
<%= f.input :email, :placeholder => "Email Address", :input_html=>{:class => "login username-field"} %>
<%= f.input :password, :placeholder => "Password", :input_html=>{:class => "login password-field"} %>
<%= f.input :password_confirmation, :placeholder => "Password Confirmation", :input_html=>{:class => "login password-field"} %>
</div>
<div class="login-actions">
<%= f.button :submit, "Sign Up", :class => 'button btn btn-warning btn-large' %>
</div>
<% end %>
</div>
</div>