Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8043687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T04:59:07+00:00 2026-06-05T04:59:07+00:00

I was wondering how to determine what page a :delete request is coming from?

  • 0

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.

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.

{"_method"=>"delete", "authenticity_token"=>"xNsfq27sBrpssTO8sk0aAzzIu8cvnFJEZ30c17Q+BCM=",
"action"=>"destroy", "controller"=>"pub_messages", "id"=>"33"}

In my destroy action, I have:

def destroy
    @pub_message = PubMessage.find_by_id(params[:id])
    @pub_message.destroy
    redirect_to user_path(@pub_message.to_id)
end

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.

Where I show the delete option in my view is…

<% if current_user == feed_item.user or current_user == feed_item.to %>
   <%= link_to "delete", feed_item,     method: :delete,
                                        confirm: "You sure?",
                                        title: feed_item.content %>
<% end %>

How can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T04:59:09+00:00Added an answer on June 5, 2026 at 4:59 am

    You can redirect_to :back, as described here. That will take you back to the HTTP_REFERER from the request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to be able to determine which page the user just came from
Wondering if there is any way to get the lambda expressions that result from
I was wondering if it possible to determine if the user has enabled the
I am wondering how to stack images that use a percentage value to determine
I'm wondering if there's some kind of criteria that can be used to determine
I was wondering if it was possible to determine from which column a coalesce
I was wondering if it's possible to determine what kind of iPhone (for example)
I am wondering if it possible to determine if an accepted socket connection has
Wondering if anyone can suggest a good file replication tool that will replicate across
Wondering if there is a good way to generate temporary URLs that expire in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.