Permalink
Browse files

support underscores in element_name

    A possible underscore in a rails resource would be replaced by a
    hyphen in a xml response, eg. 'ex_user' becomes '<ex-user>'.
    This change normalizes the response to correctly parse and return xml objects.
  • Loading branch information...
1 parent ec52c2b commit b23285646d0eb092f60161c2b4d43d1c1ee927d9 Andreas Putzo (NMMN) committed Oct 18, 2011
Showing with 3 additions and 3 deletions.
  1. +3 −3 ActiveResource.php
View
@@ -531,8 +531,8 @@ function _send_and_receive ($url, $method, $data = array ()) {
// parse XML response
$xml = new SimpleXMLElement ($res);
-
- if ($xml->getName () == $this->element_name_plural) {
+ // normalize xml element name in case rails ressource contains an underscore
+ if (str_replace("-","_", $xml->getName ()) == $this->element_name_plural) {
// multiple
$res = array ();
$cls = get_class ($this);
@@ -670,4 +670,4 @@ function set ($k, $v = false) {
}
}
-?>
+?>

0 comments on commit b232856

Please sign in to comment.