2

I have Devise gem for user authentication. Basically, I want to override registrations_controller.rb in Devise gem locally. The code in gem:

class Devise::RegistrationsController < DeviseController
   ...
    def update
        ...(need to override)
    end
end

I want to redirect user to other page if particular attribute in edit_form is selected.

Ilya Cherevkov
  • 1,743
  • 2
  • 17
  • 47

1 Answers1

2

I would advise against overriding that method. Instead, take a look at the Wiki page about custom redirects after a profile edit. It explains to override this method:

def after_update_path_for(resource)
  user_path(resource)
end

You could return different paths based on your attribute, so for example

def after_update_path_for(resource)
  resource.foo? ? foo_path : bar_path
end
Thilo
  • 17,565
  • 5
  • 68
  • 84
  • thanks it works. I found also this discussion http://stackoverflow.com/questions/3546289/override-devise-registrations-controller, just added devise_for :users, controllers: { registrations: "registrations" } in routes.rb and I can override it – Ilya Cherevkov Nov 24 '12 at 23:43