-
Notifications
You must be signed in to change notification settings - Fork 5.5k
How To: Customize the redirect after a user edits their profile
tekn0t edited this page Feb 15, 2011
·
11 revisions
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:
- Make sure you already have a copy of the registrations_controller.rb from Devise in your /app/controllers directory (check Configuring Controller in Devise README for more information).
- In this controller file, add this protected/private method:
def after_update_path_for(resource)
edit_user_registration_path # You can put whatever path you want here
end
The above code, will redirect the user back to the edit page, after the form submits with success.
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
end
Where 'users#root' is the controller/action you want to redirect to.