# Key Value Json ActiveModel::Errors

**URL:** <https://www.ruby-forum.com/t/key-value-json-activemodel-errors/195135>\
**Category:** Rails\
**Created:** [September 17, 2010, 2:34pm UTC](https://www.ruby-forum.com/t/key-value-json-activemodel-errors/195135 "2010-09-17T14:34:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![fabiokr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/cdc98d/32.png) [@fabiokr](https://www.ruby-forum.com/u/fabiokr)\
**Post date:** [September 17, 2010, 2:34pm UTC](https://www.ruby-forum.com/t/key-value-json-activemodel-errors/195135/1 "2010-09-17T14:34:30Z")

</div>

Hi all,

I’m using Rails 3.0, and I have a model which validates if the  
attribute :name is present. On my my views, I use Jquery to submit the  
form which creates the model. If the name is not present, Rails  
returns something like this Json:

[‘Name is a required value’]

Is there a way to make it return something like this?

[‘name’: ‘Name is a required value’]

This way I could search on my form which field is invalid and add an  
error class to it, etc.
