I was playing around with ActiveResource from the edge rails revision
6032, and had a nightmare trying to get returned errors from my
RESTful controller.
After a long search, I found out in here: http://dev.rubyonrails.org/
browser/trunk/activeresource/test/base_errors_test.rb?rev=6032
on line 7 that you supposed to return http status code 422 along with
your error xml!!
so suppose you have code like this:
format.xml { render :xml => @user.errors.to_xml }
active resource will die horribly!!
The correct way is format.xml { render :xml =>
@user.errors.to_xml, :status => 422 }
I was curious about what is this mysterious status code, so I searched
in google, wikipedia, etc…
Could find it!! What the heck does 422 mean?!
Also found some change logs here documenting this:
http://dev.rubyonrails.org/browser/trunk/activeresource/CHANGELOG?rev=6032
But I’m still unsatisfied about it! Did some one in rails developement
team just came up with his own error code?
Hopefully that’s not the case…
Anyone knows what does 422 mean?