title: redirect back to current page using omniauth and devise
body: <p>I want to redirect back to current page after oauth signin, and I followed <a href="https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign-in" rel="nofollow">this Devise wiki</a> and did the following:</p>
  
  <pre><code>  def after_sign_in_path_for(resource)
      sign_in_url = new_user_session_url
      if request.referer == sign_in_url
        super
      else
        request.env['omniauth.origin'] || stored_location_for(resource) || request.referer || root_path
      end
    end
  </code></pre>
  
  <p><code>request.env['omniauth.origin']</code> is <a href="http://www.bubutravel.com/users/sign_in" rel="nofollow">http://www.bubutravel.com/users/sign_in</a></p>
  
  <p><code>stored_location_for(resource)</code> is nil</p>
  
  <p><code>request.referer</code> is <a href="http://openapi.qzone.qq.com/oauth/[omitted]" rel="nofollow">http://openapi.qzone.qq.com/oauth/[omitted]</a> (my provider)</p>
  
  <p>So after my omniauth login, I get redirected to the provider urls again.</p>
  
  <p>Is the wiki outdated? What's the recommended way to do omniauth login redirect to current page?</p>