Friday, September 17, 2010

[Rails] 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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate