fertech
fertech

Reputation: 19

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

Upvotes: 0

Views: 3883

Answers (2)

shajin
shajin

Reputation: 3264

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.

Upvotes: 0

rubish
rubish

Reputation: 10907

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.

Upvotes: 2

Related Questions