Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

How To: Customize the redirect after a user edits their profile

pnc edited this page · 9 revisions
Clone this wiki locally

Normally, after a user edits their profile they are redirected to the root_path. To have Devise redirect to a custom route after an update, follow these steps:

  1. Sub-class Devise's registration controller.
  2. Override the after_update_path_for(resource) method.
  3. Configure Devise's routing.

Example subclass/override (registrations_controller.rb):

class RegistrationsController < Devise::RegistrationsController


    def after_update_path_for(resource)

Example routing config (in routes.rb):

devise_for :users, :controllers => { :registrations => :registrations }

The above code, will redirect the user back to the edit page, after the form submits with success. Depending on how you have configured your registrations views (if at all) you may need to move them into a different package.

Alternatively, you can define user_root in your config/routes.rb:-

devise_for :users do
 get 'users', :to => 'users#show', :as => :user_root # Rails 3

Where 'users#show' is the controller/action you want to redirect to.

...or (though not quite as elegant) you can just add a new match clause to your config/routes.rb:

match 'user_root' => 'users#show'
Something went wrong with that request. Please try again.