In rails how do I remember which page user left at with user login.
When same user comes back he lands on the same page.
I am new to rails not sure how I can approach this problem.
Is there any gem to implement this ?
Thanks
In rails how do I remember which page user left at with user login.
When same user comes back he lands on the same page.
I am new to rails not sure how I can approach this problem.
Is there any gem to implement this ?
Thanks
You can store the last page a user visited in a cookie. Cookies are sent in each request from the browser.
last_visited_path
)The problem here is how you decide if you should redirect a user or allow them to visit the requested page. Because you probably only want to redirect them when they just access your website via link, but once they are already on your website you should allow them to navigate to the page they want instead of redirecting them always to 1 page.
To solve that you could check the Referrer
header: if it's present and it's your website domain (i.e. the request was made from your website) then don't redirect, otherwise redirect.