This project is archived and is in readonly mode.
ActiveResource not picking up (validation) errors in 2.3.4
Reported by Vanne | October 17th, 2009 @ 08:16 PM
on the server side (2.3.4 app using ActiveRecord models:
format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }
received on client side (2.3.4 app using ActiveResource
models)
HTTP/1.1 422
Connection: close
Content-Type: application/xml; charset=utf-8
Date: Sat, 17 Oct 2009 18:11:16 GMT
Server: WEBrick/1.3.1 (Ruby/1.8.7/2008-08-11)
X-Runtime: 11
Content-Length: 101
Cache-Control: no-cache
<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Username cannot be empty!</error>
</errors>
@participant.save does return false but there are no errors available!
Went back to 2.3.3 on client side and all works well.
See also http://groups.google.com/group/rubyonrails-talk/browse_thread/threa...
Comments and changes to this ticket
-
James Brennan October 23rd, 2009 @ 11:18 PM
I'm seeing the same error. It's very possible that this is being caused by the case/when block starting on line 262 of validations.rb
case error.response['Content-Type'] when 'application/xml' errors.from_xml(error.response.body) when 'application/json' errors.from_json(error.response.body) end false
I'm about to write a patch, unless someone else has already done it?
-
James Brennan October 23rd, 2009 @ 11:19 PM
My last post wasn't entirely clear. I'm seeing it fail when the error.response['Content-Type'] = "application/xml; charset=utf-8"
-
Łukasz Pinkosz November 3rd, 2009 @ 12:46 PM
I also came across this issue.
When I call this on my remote service:render :xml => @my_object.errors, :status => :unprocessable_entity
"application/xml; charset=utf-8"
case error.response['Content-Type']
when /application\/xml/ errors.from_xml(error.response.body) when /application\/json/ errors.from_json(error.response.body) end</code>
-
JackC November 18th, 2009 @ 05:19 PM
It looks like this has been fixed in 2-3-stable.
http://github.com/rails/rails/commit/1488c6cc9e6237ce794e3c4a620162...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Referenced by
- 1956 [PATCH] json validations errors for ActiveResource ticket #3386 is a duplicate of the regression