From 238fd0b3ff1372b6bb26a0df8726e70cfb892a43 Mon Sep 17 00:00:00 2001 From: Skud Date: Wed, 21 Aug 2013 22:51:40 +1000 Subject: [PATCH] don't redirect to homepage after signin --- app/controllers/application_controller.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5b50c25f3..556f811e6 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,6 +3,20 @@ class ApplicationController < ActionController::Base include ApplicationHelper + after_filter :store_location + + def store_location + # store last url - this is needed for post-login redirect to whatever the user last visited. + if (request.fullpath != new_member_session_path && \ + !request.xhr?) # don't store ajax calls + session[:previous_url] = request.fullpath + end + end + + def after_sign_in_path_for(resource) + session[:previous_url] || root_path + end + # tweak CanCan defaults because we don't have a "current_user" method # this means that we use current_user in specs but current_member everywhere # else in the code.