在我的 Rails 应用程序中,我希望users
在销毁他们自己的帐户之前输入他们的密码。
因此,在我的routes.rb中,我将其添加到了我的user
资源中:
resources :users do
member do
get :terminate
end
end
在我的terminate.html.erb中,我有这个简单的形式:
<%= form_for(:user, :controller => "users", :action => "destroy", :html => {:method => "delete"}) do |f| %>
<%= f.label :password %><br/>
<%= f.password_field :password %>
<%= f.submit "Terminate account" %><br/>
<% end %>
在我的users_controller.rb我有这个:
def terminate
@user = User.find(params[:id])
@title = "Terminate your account"
end
def destroy
# make sure entered password is correct etc...
@user.destroy
flash[:success] = "Your account was terminated."
redirect_to root_path
end
但是,当我单击提交时,我收到此错误:
No route matches [DELETE] "/en/users/7/terminate"
我在这里想念什么?
谢谢你的帮助。