I would advise overriding the destroy method on your user model to just do update_attribute(:deleted_at, Time.current) (instead of actually destroying), but this deviation from the standard API may become burdensome in the future, so here's how to change the controller.
The developer has a bunch of default controllers. The best way to configure them is to create your own controller that inherits the corresponding controller. In this case, we are talking about Devise::RegistrationsController - which is easily recognized when looking at the source. So create a new controller.
class RegistrationsController < Devise::RegistrationsController end
Now we have our own controller that completely inherits all the logic provided by the application. The next step is to suggest the developer to use it instead of the standard one. On your routes, you have the line devise_for . It must be modified to enable the registration controller.
devise_for :users, :controllers => { :registrations => 'registrations' }
This seems strange, but it makes sense, because by default it is “developing / registering”, and not just “registering”.
The next step is to override the destroy action in the registration controller. When you use registration_path(:user), :method => :delete is where it binds. To destroy action of the registration controller.
The following is currently being developed.
def destroy resource.destroy set_flash_message :notice, :destroyed sign_out_and_redirect(self.resource) end
Instead, we can use this code. First add a new method to the User model.
class User < ActiveRecord::Base def soft_delete
You should now be tuned. Use scopes to filter out remote users.
Max Chernyak aka hakunin Feb 28 '11 at 10:50 2011-02-28 10:50
source share