【问题标题】:What is the correct way to allow a user to delete their account with Devise?允许用户使用 Devise 删除其帐户的正确方法是什么?
【发布时间】:2011-05-30 14:34:42
【问题描述】:

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

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

devise_for :users, :path_names => {:sign_up => "注册"}, :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

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

【问题讨论】:

  • 生成的button_to的URL是什么?

标签: ruby-on-rails devise


【解决方案1】:

您正在使用命名路由。

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

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

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

【讨论】:

    猜你喜欢
    • 2016-01-23
    • 2016-10-05
    • 1970-01-01
    • 1970-01-01
    • 2016-10-29
    • 1970-01-01
    • 1970-01-01
    • 2018-01-28
    • 2018-03-15
    相关资源
    最近更新 更多