title: Redirecting Devise After Sign Out
body: <p>What's the best practice for redirecting the user, using Devise, back to the page she is currently on after she logs out?</p>
  
  <p>The <a href="https://github.com/plataformatec/devise/wiki/How-To%3a-Change-the-redirect-path-after-destroying-a-session-i.e.-signing-out">devise docs</a> say to override the following (in your application controller):</p>
  
  <pre><code>def after_sign_out_path_for(resource_or_scope)
    # logic here
  end
  </code></pre>
  
  <p>Which is easy enough. However, I'm setting the previous page to be a session variable, like this:</p>
  
  <pre><code>session[:return_to] = request.fullpath
  </code></pre>
  
  <p>The problem is that when you sign out, the session is destroyed, and the top method occurs AFTER the session is destroyed, meaning you no longer have access to it. I'm thinking of putting it in a class variable or something similar, but wanted to see what SO thought.</p>