diff --git a/lib/devise/failure_app.rb b/lib/devise/failure_app.rb
index <HASH>..<HASH> 100644
--- a/lib/devise/failure_app.rb
+++ b/lib/devise/failure_app.rb
@@ -47,7 +47,7 @@ module Devise
     def redirect
       store_location!
       flash[:alert] = i18n_message unless flash[:notice]
-      redirect_to send(:"new_#{scope}_session_path")
+      redirect_to redirect_url
     end
 
   protected
@@ -63,6 +63,10 @@ module Devise
       end
     end
 
+    def redirect_url
+      send(:"new_#{scope}_session_path")
+    end
+
     def http_auth?
       !Devise.navigational_formats.include?(request.format.to_sym) || request.xhr?
     end
Extract redirect_url from failure app to its own method.