Hemant Bhargava wrote: > Guyz, > > How to retain form data while redirecting back to same page? i do not > want to work with sessions option. Any other way ..? I mean i am > creating a record and after hitting submit button one of my validation > failed and the form redirects to the same page where i have to fill the > form values again. But this time every text field value are gone..
Controllers typically do not redirect upon validation failures. If you simply render the page again your form data will be available and the Rails framework will kindly repopulate the form fields for you automatically. If you want to know what that code looks like just run a scaffold generator in new Rails project. Follow that pattern in your own controllers and you'll save yourself a lot of headaches. That being said... a redirect is going to lose the context of the previous request. HTTP is a stateless protocol. This is the reason cookies and sessions exist, and a primary reason why frameworks, such as Rails, are needed. -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.