title: Determine which page a :delete request is coming from
body: <p>I was wondering how to determine what page a :delete request is coming from? For example, I have a wall post that appears on both a user’s home page and show page. When a user deletes a post from the home page, I would want the user to be redirected to the home page while if he deleted it from his show (profile) page, I would want the user to get redirected back there. The issue is though, I’m having trouble differentiating where its coming from.</p>
  
  <p>I understand that in :delete requests, you can't pass in hidden values since it’s not a :post. I’ve tried checking the params, but they all wind up being the same. They have the same :method, :controller, and :action i.e.</p>
  
  <pre><code>{"_method"=&gt;"delete", "authenticity_token"=&gt;"xNsfq27sBrpssTO8sk0aAzzIu8cvnFJEZ30c17Q+BCM=",
  "action"=&gt;"destroy", "controller"=&gt;"pub_messages", "id"=&gt;"33"}
  </code></pre>
  
  <p>In my destroy action, I have:   </p>
  
  <pre><code>def destroy
      @pub_message = PubMessage.find_by_id(params[:id])
      @pub_message.destroy
      redirect_to user_path(@pub_message.to_id)
  end
  </code></pre>
  
  <p>But instead of always redirecting back to the user_path, I want to redirect to the root_path but just can't figure out when the user is issuing the destroy action while on the home page or not.</p>
  
  <p>Where I show the delete option in my view is...</p>
  
  <pre><code>&lt;% if current_user == feed_item.user or current_user == feed_item.to %&gt;
     &lt;%= link_to "delete", feed_item,     method: :delete,
                                          confirm: "You sure?",
                                          title: feed_item.content %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>How can I fix this?</p>