简体   繁体   English

超时后rails + dev重定向到家

[英]rails + devise redirect to home after timeout

I am using devise 1.4.0. 我正在使用装置1.4.0。 What I need is to configure the url to root after the session has timed out ( instead of redirecting to login). 我需要的是在会话超时后将URL配置为root(而不是重定向到登录)。 Anybody know how to do this? 有人知道该怎么做吗? Thanks 谢谢

You can override the after_sign_out_path_for method. 您可以覆盖after_sign_out_path_for方法。 Add this method in your ApplicationController as a private method: 将此方法添加到ApplicationController作为private方法:

def after_sign_out_path_for(resource)
  root_path
end

Take a look at devise wiki for details. 看一下devise wiki了解详细信息。

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. 您要在routes.rb文件中设置home_path,这将覆盖默认路由。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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