# Acts\_as\_authenticated, reset\_session, and redirect\_back\_or\_d

**URL:** <https://www.ruby-forum.com/t/acts-as-authenticated-reset-session-and-redirect-back-or-d/108208>\
**Category:** Rails\
**Created:** [June 30, 2007, 1:10am UTC](https://www.ruby-forum.com/t/acts-as-authenticated-reset-session-and-redirect-back-or-d/108208 "2007-06-30T01:10:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmcfab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/838e76/32.png) [@cmcfab](https://www.ruby-forum.com/u/cmcfab)\
**Post date:** [June 30, 2007, 1:10am UTC](https://www.ruby-forum.com/t/acts-as-authenticated-reset-session-and-redirect-back-or-d/108208/1 "2007-06-30T01:10:36Z")

</div>

Just a question and an FYI  
I just installed rails and acts\_as\_authenticated and was setting up a  
site. Everything works fine except that in the AccountController that  
I generated the calls to the routine redirect\_back\_or\_default don’t  
work because the call just before it to reset\_session clears the  
session[:return\_to] that the method uses to set where it will  
redirect.

I ended up adding a version of redirect\_back\_or\_default to the account  
controller that works for me (and as a benefit it keeps me from having  
to set session[:return\_to] which stunk)

def redirect\_back\_or\_default(default)  
if request.env[“HTTP\_REFERER”].nil?  
redirect\_to default  
else  
redirect\_to(request.env[“HTTP\_REFERER”]) # same as  
redirect\_to :back  
end  
end

My question is, am I just missing something, is there a different  
version of code out there, or is this thing really broken.

Anyway, thanks,  
Charles C.
