has_secure_password验证为"can't be blank"



我有密码验证消息正确显示的问题。我的表单生成正确的错误消息,但它也显示了一个我不需要的通用错误,它的状态是"不能是空白的"。我找不到这是从哪里来的,但已经看到它可能链接到模型中包含的has_secure_password ?

user.rb

validates_presence_of :password, { message: "Please enter your password."}

new.html.erb

<% @admin.errors.messages.each do |attr, message| %>
 <li class="form-errors"><%= message.join(", ") %></li>
<% end %>

验证显示消息

can't be blank, Please enter your password.

您可能忘记在用户控制器

中允许:password和:password_confirmation参数。

最新更新