Hey all,

Recently I've been looking into on how to return back to a previous 
referring URL and and the most common approach is:

redirect_to session[:return_to]
 

But some recommend:

redirect_to(session.delete(:return_to) || default)
 

How I understand it, in the second example we call session.delete so it 
will clear the return path since we will no longer need it, and we also use 
|| to fall back to default URL in case the session is nil. Kind of makes 
sense, but what I am trying to understand is (and I couldn't find it 
anywhere explained) what are the implications of -not- using 
session.delete, how is it better, is it a security thing? And also falling 
back to default, in what cases can a session be nil? If there are other 
checks present (I am using Devise) should this be necessary?

Hope my questions make sense. Thank you.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/t2Zxt8NP4hYJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to