在我的 ruby on rails 项目中,我使用 devise 作为身份验证插件。现在我已将更改密码功能添加到项目中,提交表单时出现错误No route matches "/users/update_password"
这是我的更新密码代码
def update_password
@user = User.find(current_user.id)
if @user.update_attributes(params[:user])
# Sign in the user by passing validation in case his password changed
sign_in @user, :bypass => true
redirect_to root_path
else
render "edit"
end
end
这是我的路线详情
resources :users, :only => [] do
collection do
get 'current'
get 'edit'
post 'update_password'
end
end
这是我的编辑表格
<div id="loginForm">
<div id="loginHeader"><h3>Change Password</h3></div>
<div id="loginContent">
<%= form_for(@user, :url => { :action => "update_password" }) do |f| %>
<p><%= f.password_field :current_password, :class => "login_txt", :placeholder => "We need your current password to confirm your changes", :autocomplete => "off" %></p>
<p><%= f.password_field :password, :class => "login_txt", :placeholder => "New password", :autocomplete => "off" %></p>
<p><%= f.password_field :password_confirmation, :class => "login_txt", :placeholder => "Confirm password", :autocomplete => "off" %></p>
<p>
<input id="user_submit" name="commit" type="submit" value="Update Password" class="login_btn" />
</p>
<% end %>
</div>
</div>
谁能帮我解决这个问题
非常感谢