How To: Redirect to a specific page on successful sign in · heartcombo/devise Wiki

Ask questions Research chat →

https://github.com/heartcombo/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in · scraped

rails

Attachments

Scraped Content

— 118 words · 2026-02-14 03:18:30 UTC ·

Excerpt

config/routes.rb namespace :user do root :to => "welcome#index" end This does not work with Rails 3.0.7 in production mode. Use this instead: match '/user' => "welcome#index", :as => :user_root For Rails 6, use: get '/user' => "welcome#index", :as => :user_root If you are using a gem that reads to URI for certain processing (like simple-navigation) the new URI will be '/users' even though you are at the '/welcome' URI (highlight is lost in simple-navigation and submenus are not rendered). So the solution can be achieved with this: app/controllers/application_controller.rb def after_sign_in_path_for(resource) stored_location_for(resource) || welcome_path end To make the above work, the root path has to be publicly visible! The resulting URI will be '/welcome', which can be properly processed.
config/routes.rb namespace :user do root :to => "welcome#index" end This does not work with Rails 3.0.7 in production mode. Use this instead: match '/user' => "welcome#index", :as => :user_root For Rails 6, use: get '/user' => "welcome#index", :as => :user_root If you are using a gem that reads to URI for certain processing (like simple-navigation) the new URI will be '/users' even though you are at the '/welcome' URI (highlight is lost in simple-navigation and submenus are not rendered). So the solution can be achieved with this: app/controllers/application_controller.rb def after_sign_in_path_for(resource) stored_location_for(resource) || welcome_path end To make the above work, the root path has to be publicly visible! The resulting URI will be '/welcome', which can be properly processed.

Visibility

Visible to everyone

Reading Status

Related Bookmarks

My Note


Saved!

Annotations

Export as Markdown
+ Annotate selection

Add Annotation