This project is archived and is in readonly mode.
ActiveResource doesn't parse validations when extended content type
-
Jake Scruggs
I've also had problems with this when using Rails 2.3.4 to consume a resource from a Rails 2.1.1 app. I believe this can be fixed by changing validations.rb in the ActiveResource(2.3.4) gem starting with line 258:
def save_with_validation save_without_validation true rescue ResourceInvalid => error 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 endIn the above lines I've changed the case statement to use regex instead of doing a strict string match.
Any reader of this ticket who wants to fix their own app can use this monkey patch:
module ActiveResource # Errors returned from the API layer were not getting put into our User object as of Rails 2.3.4 class Base def save save_without_validation true rescue ResourceInvalid => error 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 end end end -
CancelProfileIsBroken
- Tag set to bugmash
-
Rizwan Reza
- State changed from new to resolved
- Tag changed from bugmash to activeresource
- Milestone set to 2.3.6
This has been resolved in the 2-3-stable.
-
Jatinder Singh
For the reference, it was resolved in http://github.com/rails/rails/commit/1488c6cc9e6237ce794e3c4a620162...
-
Rizwan Reza
Thanks Jatinder! :)