From 07b9d80604f130c5958e24651e73e889c6e43bb7 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Fri, 11 Jul 2014 12:24:11 +0200 Subject: Use devise stored_location to redirect after signing for both public and private pages. --- app/controllers/application_controller.rb | 2 +- app/controllers/sessions_controller.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 app/controllers/sessions_controller.rb (limited to 'app') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9cc63e5c1b9..d0546a441e1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -68,7 +68,7 @@ class ApplicationController < ActionController::Base flash[:alert] = "Your account is blocked. Retry when an admin has unblocked it." new_user_session_path else - super + stored_location_for(:redirect) || stored_location_for(resource) || root_path end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 00000000000..9b7bd94c3a2 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,14 @@ +class SessionsController < Devise::SessionsController + + def new + if request.referer.present? + store_location_for(:redirect, URI(request.referer).path) + end + + super + end + + def create + super + end +end -- cgit v1.2.1