我必须为商店提供注册设施。在那里用户必须输入姓名、密码、确认密码。但是当我尝试输入不同的密码进行确认时,它没有显示任何错误并且用户已成功注册。这是 UserMODEl 中的代码
class User < ActiveRecord::Base
attr_accessible :name, :password_digest, :password, :password_confirmation
validates :name, :presence => true, :uniqueness => true
validates :password, :presence =>true, :confirmation =>true
validates_confirmation_of :password
has_secure_password
end
我在views/users/_form.html.erb中的代码如下..
<div class="depot_form">
<%= form_for(@user) do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<fieldset>
<legend>Enter User Details</legend>
<div >
<%= f.label :name %>:
<%= f.text_field :name, :size => 40 %>
</div>
<div>
<%= f.label :password, 'Password' %>:
<%= f.password_field :password, :size => 40 %>
</div>
<div>
<%= f.label :password_confirmation, 'Confirm Password' %>:
<%= f.password_field :password_confirmation, :size => 40 %>
</div>
<div>
<%= f.submit %>
</div>
</fieldset>
<% end %>
</div>
我经历了各种解决方案和修改,但徒劳无功......请提供任何帮助..