Best practices: form fails, now what


Situation: A user submits a form. The inputs are in some way
invalid. You present the original form.

Question: How do you present the original form as the user had it
filled out (so they can correct it) rather than in its original state
(requiring them to re-enter everything).

I have more or less hackish ways of doing this, but wondered how
other people were doing it.



It’s easiest if you post back to the same action that the form is in.
Just make sure you set all the class variables. eg:

def login
@user = params[:user] ||
#login, redirect