I’m looking for some example code on displaying validation errors in a form that is submitted via json to rails 3.1. The form is using formtastic-bootstrap, and is displayed as a JQuery dialog. The request is sent to the server as a xhr request with JSON data. The form is created with formtastic, and displayed by JQuery in a modal fashion.
It’s not obvious if I should send back the raw error messages in a JSON, or maybe the HTML in the JSON to be applied to a div that shows validation errors.
I would just use the jQuery ujs capabilities and return the full html.
Here is an example:
views/resources/_form.html.erb:
views/resources/new.html.erb:
controllers/resources_controller.rb: