ApplicationController: before_filter :session_expiry, :except => [:login, :logout] before_filter :update_activity_time, :except => [:login, :logout] def session_expiry @time_left = (session[:expires_at] - Time.now).to_i unless @time_left > 0 reset_session flash[:error] = 'Sua sess?o expirou. Favor entrar novamente.' redirect_to :controller => 'login', :action => 'login' end end def update_activity_time session[:expires_at] = 60.minutes.from_now end