# Redirect :back clears my form Data

**URL:** <https://www.ruby-forum.com/t/redirect-back-clears-my-form-data/142648>\
**Category:** Rails\
**Created:** [July 10, 2008, 1:11am UTC](https://www.ruby-forum.com/t/redirect-back-clears-my-form-data/142648 "2008-07-10T01:11:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mitch\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@mitch\_newbie](https://www.ruby-forum.com/u/mitch_newbie)\
**Post date:** [July 10, 2008, 1:11am UTC](https://www.ruby-forum.com/t/redirect-back-clears-my-form-data/142648/1 "2008-07-10T01:11:31Z")

</div>

I have a login form on the left side of a page.

The user can always log in at any time this way.

when they do I use redirect :back as an easy way to get back to the page  
they were viewing before they attempted to log in.

Problem I am having is that if they make an error when logging in and I  
redirect them back the username won’t show up because of the redirect.

Is there an Rails way of getting the username to show up in the form so  
they can correct any typos.

The password field being empty works well in this case.

Thank you in advance.

Mitch

---

<div class="post-metadata">

**Author:** ![mitch\_newbie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea5d25/32.png) [@mitch\_newbie](https://www.ruby-forum.com/u/mitch_newbie)\
**Post date:** [July 10, 2008, 1:20am UTC](https://www.ruby-forum.com/t/redirect-back-clears-my-form-data/142648/2 "2008-07-10T01:20:57Z")

</div>

> and I  
> redirect them back the username won’t show up because of the redirect.
> 
> Is there an Rails way of getting the username to show up in the form  
> so  
> they can correct any typos.
> 
> The password field being empty works well in this case.

redirect :back and the ‘back button’ aren’t the same thing. The  
former is just a convenient shortcut for sending the user to another  
page via an HTTP redirect.

That said, sometimes the back button doesn’t save form fields either.

Store the username in a cookie and use some javascript to prefill the  
login box if that cookie exists.

-philip
