Forum: Ruby on Rails Best practices: form fails, now what...

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0ab6a5abab167b409f58d280dc59a229?d=identicon&s=25 Faisal N Jawdat (Guest)
on 2007-03-03 09:36
(Received via mailing list)
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.

-faisal
689107856b5a794181624031eb6df776?d=identicon&s=25 flukus@gmail.com (Guest)
on 2007-03-03 12:09
(Received via mailing list)
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] || User.new
if request.post?
#login, redirect
end
end
This topic is locked and can not be replied to.