1
votes

I'm using devise for user accounts. What is the correct way to let users delete their accounts?

My devise setup already has an overridden registrations controller

devise_for :users, :path_names => {:sign_up => "register"}, :controllers => {:registrations => 'registrations'}

This is how I've tried to setup the account removal process:

registrations_controller.rb

def delete_account
    #remove data associated with account, then the user object itself
end

routes.rb

  map.delete_account 'delete_account', :controller => 'registrations', :action => 'delete_account'

and try to link to it

<%= button_to 'temo', delete_account_path %>

I get this error when I click the link

Unknown action
AbstractController::ActionNotFound

Why isn't this working? Thanks for reading.

1
What is the generated URL of the button_to?vonconrad

1 Answers

0
votes

You're using a named route.

map.delete_account 'delete_account', :controller => 'registrations', :action => 'delete_account'

In which case you can do this

<%= button_to 'temo', '/delete_account' %>