简体   繁体   中英

Rails: redirect back to previous page after sign in / sign up

I am using Rails and devise for user authentication, I don't know how to redirect the user back to the previous page after successful sign in/sign up.

I know about after_sign_in_path_for , but I don't know what I should write inside.

You can write custom sessions controller for devise login and use request.referrer to get the URL of the page the user is coming from. Then just redirect back to the previous page after login. Also refer this doc . You could go by one of the methods. Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM