I have two edit pages in my application. After the changes have been saved, I want to redirect the user to another page depending on whether they are on the "/ info" or "/ edit" page. I am trying to use request.referer to find the path the user has come to decide where to redirect him.
(If they are in '/ info', they came from '/ users / sign_up')
controller
if URI(request.referer).path == '/users/sign_up'
redirect_to root_path, notice: "Welcome"
else
redirect_to user_path(@user)
end
The problem is that it redirects to user_path no matter where the user is located.
(BTW, I am not configured to use request.referer to solve this problem. I also tried to use 'current_uri = request.env [' PATH_INFO ']' with the same luck)
source
share