保存数据库的字段是 password_digest model 文件:
#密码(password)
validates_presence_of :password, :on=>:create, :message => "密码不能为空"
validates_length_of :password, :on=>:create,:in => 6..15, :message => "密码长度在6-15"
validates_confirmation_of :password,:on=>:create, :message => "两次输入密码不一致"
has_secure_password
做个重置密码,
<%= form_tag(:controller => 'user_index', :action => 'setting_commit') do %>
<li style="margin-top:30px">
<p>旧密码:</p>
<%= password_field_tag("old_password") %>
<div class="PublicNoticAreaRed"><%= flash[:notice] %></div></br>
<p>新密码(长度6-15):</p>
<%= password_field_tag("password") %></br>
<%= error_message_on @user, :password %>
<p>再次确认新密码:</p>
<%= password_field_tag("password_confirmation") %>
</li>
<% end %>
controller 文件里:
old_password = params[:old_password]
new_password = params[:new_password]
new_password_confirmation = params[:new_password_confirmation]
然后要怎么更新密码呢?