I would like to do rails session timeout and redirect to sign in page after session expire.
This is my application controller and seem not working.
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
before_filter :session_expires, :only => [:login]
def session_expires
a = session[:expires_at]
b = Time.now
minutes = (a - b)/1.minute
if b > a
reset_session
flash[:error] = 'Session Expire !'
render "sessions/new"
end
end
end
I am not sure, I need to use Jquery or Ajax to make it work. Can anyone give me some idea or some good tutorial i can follow. Thank in million.