I have a simple scenario where I want to request a page. The request format is text/html. If there is some error in the controller/action logic for that request, I want to get an error message. The twist is that I want this error message to be communicated to be with a javascript response type (i.e. no page refresh). If there are no errors, then I want the page to be loaded via the expected text/html response type.
Basically, I want two different response types depending on whether there is an error or not. Is this doable in rails 3? If so, what is best practice?
A quick code sample would be much appreciated.
Thanks.
Sure it’s doable!
I would do it like this: