9

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?

Ryan
  • 379
  • 1
  • 5
  • 11

3 Answers3

7

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)

alony
  • 10,725
  • 3
  • 39
  • 46
  • This gave me /users.user in my URL instead of just /users. Thoughts? – Ryan Jan 13 '12 at 02:19
  • I do have all my javascript files included. – Ryan Jan 13 '12 at 02:36
  • yes, you're right, i was confused by user_registration in the rake routes. Do all other (especially update user registration) work correctly? – alony Jan 13 '12 at 07:34
  • Yep ... all of my other deletes work as well so I know my javascript is correct. I am able to also destroy user_sessions which I know other people have had similar problems with devise but with the user session. – Ryan Jan 13 '12 at 16:26
1
<p>
  Unhappy?
  <%= link_to "Cancel my account",
      registration_path(current_user),
      data: { confirm: "Are you sure?" },
      method: :delete %>
</p>
Stephane Paquet
  • 2,315
  • 27
  • 31
0

if you are using devise just do

<%= link_to "My Account", edit_user_registration_path %>
eden
  • 1,979
  • 3
  • 16
  • 13