开发者

rails + devise redirect to home after timeout

开发者 https://www.devze.com 2023-03-23 09:52 出处:网络
I am using devise 1.4.0.What开发者_JAVA百科 I need is to configure the url to root after the session has timed out ( instead of redirecting to login).

I am using devise 1.4.0. What开发者_JAVA百科 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消