I have a friendship system where users can create new friendships from
different views. The idea is to redirect them to where they initially
requested, accepted, etc... the friendship. To do this, I need to
store the URL path from where they are sending the request. Is there a
way to save the initial URL (from where the request mas made to the
friendships controller). Any light on this?
Thanks for your time,
I use the following code to redirect them to the page they requested before they logged in. Maybe this will get you on the right path. I put it in the controller under protected.
Protect a page from unauthorized access.
session[:protected_page] = request.request_uri
flash[:notice] = “Please log in first”
redirect_to :action => “login”
Redirect to the previously requested URL (if present).
if (redirect_url = session[:protected_page])
session[:protected_page] = nil
redirect_to :action => “index”
Sean McGilvray & Sarena Byers
Identity Theft Specialist
Pre-Paid Legal Service’s, Inc. NYSE:PPD
Hi Sean thanks for the response.
I thought about a solution based on your answer, but I am not happy
with it. My solution consisted on having a before_filter on the
controllers I know there might be a call to the friendships
controller. This before_filter will be used to save the URL. And then,
have a before_filter on the application controller where I do this:
if params[:controller] != "friendships"
session[:return_to] = nil
The thing is that having this before_filter every time for every
controller doesn't seems right.