简体   繁体   中英

rails + devise redirect to home after timeout

I am using devise 1.4.0. What I need is to configure the url to root after the session has timed out ( instead of redirecting to login). Anybody know how to do this? Thanks

You can override the after_sign_out_path_for method. Add this method in your ApplicationController as a private method:

def after_sign_out_path_for(resource)
  root_path
end

Take a look at devise wiki for details.

This is the code which I am using for this purpose.

In application_controller.rb

private  
def after_sign_out_path_for(resource_or_scope)
 params[:back].nil? ? home_path : params[:back]
end

You want to set up home_path in routes.rb file.This will override the default routing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM