How to redirect by checking for a particular previous url
Posted
by
Bearish_Boring_dude
on Stack Overflow
See other posts from Stack Overflow
or by Bearish_Boring_dude
Published on 2013-10-21T18:37:47Z
Indexed on
2013/10/23
9:55 UTC
Read the original article
Hit count: 196
I have the following piece of code in my controller
def index
session[:previous_url] = URI(request.referer).path
if session[:previous_uri] != new_path
redirect_to registration_path(id: current_user.associate_username)
end
end
However this does not actually work and i get a bad URI error. I just want to check if the request came from a particular page and if not redirect it to another page. I would also like to know if there is a better way for doing this?.Thank you
© Stack Overflow or respective owner