what was i smoking ?
Some url resources are under a login ie. can only access them if a user is logged in.
approaches:
-
maintain a previous url app-wide and redirect back after sign_in. for signout maintain a list of protected actions so we do not redirect back there have to make sure circular redirects do not happen
-
before redirecting to login, store the back url and thereafter do not maintain "back" url.
(2) is much simpler. rails has "redirect :back" but it does not work for all cases
also for (1) have to code special cases. eg. /checkout -> /sign_in -> /forgot_password -> /sign_in now after sign_in the previous url is /forgot_password but should not redirect there
another case is am logged in and am at /checkout not after /signout should not get redirected to any url which requires a login because it will again take me to a /signin page
so in all respects the (2) is simpler and more error-proof. is a little more explicit though
also redirects do not work on POST requests only on GET requests can create a special GET alias url for the POST resource or call the POSTed resource programmatically and redirect to the show resource