|
|
AJAX validation in Rails
|
04/01/2006, By BigSmoke
|
This article explains how BigSmoke handled ActiveRecord validation messages and other notices caused by AJAX requests. The text is written in XHTML 2 and converted client-side to XHTML 1, which means it might be difficult to read in some outdated browsers such as IE.
The problem:
I wanted AJAX requests in Rails to result in error handling and message reporting that was at least as nice (and almost as easy) as doing the same thing without AJAX.
A solution:
Let me start with a short summary of the steps I followed to get easy, transparent error handling for AJAX requests.
Make validation errors cause a 4xx HTTP error.
Store validation error messages within the flash.
Pass the flash to the browser through the X-JSON header.
Extract the validation error messages and other flash notices from the X-JSON header using a custom AJAX responder.
Read More...
|
Rate this Ajax Articles
Rating: 8.6 out of 45 votes cast
| |
|
|
|
|
|
|
|
|
|
|
|
|