Key Value Json ActiveModel::Errors

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs