覆盖设计注册控制器后无法删除资源

时间:2011-11-10 17:17:21

标签: devise ruby-on-rails-3.1

我遵循了这个设计how to: Redirect to a specific page on successful sign up

我创建了一个新的RegistrationsController

class RegistrationsController < Devise::RegistrationsController
   def after_inactive_sign_up_path_for(resource)
     ...
   end

   def destroy
      logger.debug 'destroy user'
      ...
   end
end

我更改了routes.rb:

devise_for :users, :controllers => { :registrations => "registrations" } do
  get 'users', :to => 'profile#index', :as => :user_root
end

并在我的新RegistrationsController下移动devise/registrations/次观看。

rake routes我有:

DELETE /users(.:format)  {:action=>"destroy", :controller=>"registrations"}

after_inactive_sign_up_path_for正在发挥作用。

destroy操作不起作用:我取消帐户时

<%= button_to "Cancel my account", registration_path(resource_name), :confirm => "ok?", :method => :delete %>

我有以下错误:

The action 'destroy' could not be found for RegistrationsController

我使用Devise 1.4.5&amp; Rails 3.1

1 个答案:

答案 0 :(得分:0)

我刚遇到同样的问题。将destroy方法移动到控制器的非私有部分修复它。

相关问题