允许用户使用Devise删除其帐户的正确方法是什么?

时间:2010-12-25 08:25:17

标签: ruby-on-rails devise

我正在使用devise用户帐户。让用户删除帐户的正确方法是什么?

我的设计设置已经有一个被覆盖的注册控制器

  

devise_for:users,:path_names =>   {:sign_up => “register”} ,: controllers   => {:registrations => '注册'}

这就是我尝试设置帐户删除流程的方法:

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'

并尝试链接到它

<%= button_to 'temo', delete_account_path %>

点击链接时出现此错误

Unknown action
AbstractController::ActionNotFound

为什么这不起作用?谢谢你的阅读。

1 个答案:

答案 0 :(得分:0)

您正在使用命名路线。

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

在这种情况下你可以这样做

<%= button_to 'temo', '/delete_account' %>
相关问题