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 6718437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:58:09+00:00 2026-05-26T08:58:09+00:00

I have an application that allows an admin user to switch into another user’s

  • 0

I have an application that allows an admin user to switch into another user’s context. If the admin is in /images and switches to another user’s context, the admin will see the Images belonging to that user. I have a ContextController that switches the context, and then, upon success, redirects the user to :back.

This is great, and works well. The problem is that, if the admin is viewing /images/1, and switches into another user’s context, an error will be thrown (because Image with id=1 does not belong to that user).

One way I could handle this is to catch the error, and redirect the user to root_path. I would like a more intelligent way to handle this, however, if anybody has any ideas. Is there a nice programmatic way to check where :back points to, and extract the :action from that path?

Thanks,
Max

  • 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-05-26T08:58:10+00:00Added an answer on May 26, 2026 at 8:58 am

    :back is just using the http referer header which you can look at in request.referer It will be a full URL, so it won’t be as easy as checking the action, you’ll need to match against the full string url. Make sure to handle the case when request.referer is nil or empty as well.

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

Sidebar

Related Questions

I have an application that allows the user to download a csv. This works
I have a web application that allows a user to search on some criteria,
Let say, I have a web application that allows users to upload images and
I have a simple Desktop Facebook application that allows the user to retrieve some
So I have an rails admin system that will allow a user to choose
I have an application that allows users to write their own code in a
I have a rails application that allows searches using longitude and latitude. I have
I have a bowling web application that allows pretty detailed frame-by-frame information entry. One
I have a requirement to create a simple windows forms application that allows an
We have created a web application, using ASP.NET, that allows users to upload documents

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.