title: Friendly forwarding with a post request
body: <p>I wrote a friendly forwarding feature for my app, but it fails on post requests. Scenario as follows:</p>
  
  <ol>
  <li>User attempts to access protected page</li>
  <li>App stores url and redirects to login page</li>
  <li>User logs in and app redirects to stored url</li>
  </ol>
  
  <p>sessions_helper.rb</p>
  
  <pre><code>def store_location
    session[:return_to] = request.url
  end
  def redirect_back_or(default)
    redirect_to(session[:return_to] || default)
    session.delete(:return_to)
  end
  </code></pre>
  
  <p>application_controller.rb</p>
  
  <pre><code>def require_login
    unless !signed_in?
      store_location
      redirect_to signin_path
    end
  end
  </code></pre>
  
  <p>sessions_controller.rb</p>
  
  <pre><code>def create
    ..
    sign_in user
    redirect_back_or root_path
    ..
  end
  </code></pre>
  
  <p>This works fine, until you throw in <code>POST</code> requests.</p>
  
  <ol>
  <li>User visits <code>posts#new</code> and submits form</li>
  <li>App stores url and redirects to login page</li>
  <li>User logs in and app redirects to stored url, <strong>which fails</strong></li>
  </ol>
  
  <p><code>AbstractController::ActionNotFound at /forums/7/posts</code></p>
  
  <p><code>The action 'index' could not be found for PostsController</code></p>
  
  <pre><code>unless action_name = method_for_action(action_name)
    raise ActionNotFound, "The action '#{action}' could not be found for #{self.class.name}"
  end
  </code></pre>
  
  <p>Any idea how to get around this issue?</p>