sainaba sainu wrote:
I am doing a project on invoice. For that I have to use a page both for
crating new invoices and for updation of existing invoices. The problem
is that when an error occures, I can’t maintain the same page for error
correction. How can I redirect it from the controller ? Or can I display
ruby errors before submit of the page in ruby?
There are a couple of things you can do. The first is to do what the
scaffolded code does, which is redirect back to the edit/new form if the
object doesn’t save, and display the error messages. Take a look at the
scaffold code to see how that works - the form fields get filled out
with the same data as was submitted.
The second is a little more fun, but a little more involved. On any
change to the form data, you can submit it to an AJAX validator action,
and display any errors back to the user. When the validator comes back
with no errors, you can allow the form to be submitted to the
I’ve been meaning to try the second method out, but haven’t had a decent