Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails + devise: Trying to delete user account

When I try and delete my account in my rails app I get

No route matches "/users"

My View:

<p>We hate to see you go. <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>

My routes:

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"}

Am I missing something?

like image 261
Ryan Avatar asked Jan 11 '12 03:01

Ryan


2 Answers

According to your rake routes output, you need to use user_registration_path helper instead of just 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>

And please double check if the link is triggered with the DELETE method (if the proper js files are included)

like image 118
alony Avatar answered Oct 14 '22 16:10

alony


<p>
  Unhappy?
  <%= link_to "Cancel my account",
      registration_path(current_user),
      data: { confirm: "Are you sure?" },
      method: :delete %>
</p>
like image 28
Stephane Paquet Avatar answered Oct 14 '22 15:10

Stephane Paquet