Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/6744
Created by jimmiesh - 2011-04-26 01:22:27 UTC
When passing a :type option to to_xml, the passed type is propagated to all string attributes in the ActiveModel. For instance:
@attributes = attributes
mp = Person.new('foo' => 'string', 'bar' => 1)
puts mp.to_xml(:type => 'Person')
<?xml version="1.0" encoding="UTF-8"?>
We ran into this because ActiveRecord adds a type option when serializing has_many associations where the association class does not match the association name. For instance:
has_many :cars, :class_name => 'Automobile'
In this case, we wanted the type attribute on each car in the xml, but we don't want it on the car's string attributes :).
Please consider the attached patch for inclusion in the next release of Rails. Thanks.
Attachments saved to Gist: http://gist.github.com/971851
Attributes with :string type should not be given the type passed in m…
…odel serialization options. Closes #1058
Fix duplicate test name [#1058 state:resolved] [Dave Rothlisberger, P…