Ruby on Rails: Is there a way to tell what fields failed validation in ActiveRecord?
- by randombits
I'm attempting to create an XML builder file that tells a user to know exactly what fields failed validation in the output. I also want to display their input back to them, so that requires me figuring out which fields failed validation. Meaning if someone fails on creating a new user resource, I want to display XML that's meaningful (Besides a meaningful HTTP status number) such as:
<errors>
<user>
<email>bad@email: Invalid email format</email>
</user>
<errors>
The above is tough to do in an XML builder file without knowing what field failed. And if I just iterate over error messages, I won't know how to prob my @user object to get the value that the user supplied.