This project is archived and is in readonly mode.

#2456 ✓resolved
Jan Berkel

activeresource xml/json encoding inconsistency

Reported by Jan Berkel | April 8th, 2009 @ 02:03 PM | in 2.x

the activeresource encoding for xml/json seem to be inconsistent: xml will incude the element name as root

from activeresource/base.rb

self.class.format.encode(attributes, {:root => self.class.element_name})

whereas json will use

self.class.format.encode(attributes, options)

so when an activeresource gets saved, the decoded parameters (on the REST API side) are different, e.g.

{"city"=>nil, "name"=>"Foo Bar" }   (JSON) vs.
{"person" => { "city=>nil, "name"=> "Foo Bar" } } (XML)

so when using json, i can't just use Person.find().update_attributes(params[:person]) in my controller.

is this intentional? looks like a bug.

Comments and changes to this ticket

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

Pages