当我尝试在我的rails应用程序中删除我的帐户时,我得到了
没有路线匹配“/ users”
我的观点:
<p>We hate to see you go. <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
我的路线:
user_registration POST /users(.:format) {:action=>"create", :controller=>"devise/registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"devise/registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"devise/registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"devise/registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"devise/registrations"}
我错过了什么吗?
答案 0 :(得分:7)
根据您的rake路由输出,您需要使用user_registration_path助手而不仅仅是registration_path:
<p>
We hate to see you go.
<%= link_to "Cancel my account", user_registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.
</p>
请仔细检查链接是否使用DELETE方法触发(如果包含正确的js文件)
答案 1 :(得分:1)
<p>
Unhappy?
<%= link_to "Cancel my account",
registration_path(current_user),
data: { confirm: "Are you sure?" },
method: :delete %>
</p>
答案 2 :(得分:0)
如果您正在使用设计,请执行
<%= link_to "My Account", edit_user_registration_path %>