o: ActiveSupport::Cache::Entry :@expires_in0:@compressedF:@created_atf1327293378.879518J: @value"j{"content_type"application/javascript" class"ProcessedAsset"dependency_digest"%d37e4ef92fa097c18a8791a09632ded8" mtime"2012-01-23T15:35:54+11:00" _version"%45a9b34d2c65935f21d8f90f1e1b2836"dependency_paths[{" mtime"2012-01-23T15:35:54+11:00" digest"%8b24f53fe22da88c52b8fbba15dab596" path"g/Users/tom/Development/Percolate/edifice-forms/app/assets/javascripts/edifice-forms/show-errors.js" digest"%4692394e5061027d2f01e3648fd326f3"required_paths["g/Users/tom/Development/Percolate/edifice-forms/app/assets/javascripts/edifice-forms/show-errors.js" pathname"g/Users/tom/Development/Percolate/edifice-forms/app/assets/javascripts/edifice-forms/show-errors.js"logical_path"!edifice-forms/show-errors.js" lengthiˆ" source"ˆ(function($) { var showErrorSelector = 'form[data-form*=show_errors]'; $(showErrorSelector).live('ajax:error', function(event, request, status, error) { // CLIENT ERROR -- server-side validation failed. -- FIXME -should this be 422 only? if (request.status >= 400 && request.status < 500) { // if data is html, we replace this content of the form with the content // of the form that we've just received back var contentType = request.getResponseHeader('Content-Type'); if (/html/.test(contentType)) { // wrap in a div incase there are a bunch of floating elements, pull the form out var $new_form = $('
' + request.responseText + '
').find('#' + $(this).attr('id')); $(this).html($new_form.html()); } else if (/json/.test(contentType)) { // we will be receiving an error object back, we can pass it straight into rails_form.js $('body').append('
' + request.responseText + '
'); var errors = $.parseJSON(request.responseText); // they are using namespaced JSON if ('errors' in errors && !$.isArray(errors['errors'])) { errors = errors['errors'] } $(this).rails_form('set_errors', errors); } else { throw "edifice-forms/show-errors: Don't know how to handle dataType " + request.dataType; } } }); }(jQuery));